Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pivoter fields are wiped by options() #44

Open
Guibod opened this issue Oct 13, 2016 · 0 comments
Open

pivoter fields are wiped by options() #44

Guibod opened this issue Oct 13, 2016 · 0 comments

Comments

@Guibod
Copy link

Guibod commented Oct 13, 2016

I've stumble on this annoying bug here on python 3.4.

import unittest
from scorched.search import SolrSearch


class TestOptionsMethodWipesPivots(unittest.TestCase):
    def test_there_is_a_problem_with_pivot_by_with_facet(self):
        facet = 'facet'
        pivot = 'pivot'

        search = SolrSearch(None)
        search = search.facet_by(facet, mincount=1).pivot_by([pivot, facet], mincount=1)
        self.assertIn(pivot, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[pivot], {'mincount': 1})
        self.assertIn(facet, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[facet], {'mincount': 1})

        options = search.options()
        self.assertIn('facet.pivot', options)
        self.assertEqual(options['facet.pivot'], 'facet,pivot')

        self.assertIn(pivot, search.pivoter.fields)
        # Equals True
        self.assertEqual(search.pivoter.fields[pivot], {'mincount': 1})
        self.assertIn(facet, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[facet], {'mincount': 1})

    def test_there_is_a_problem_with_pivot_by_even_without_facet(self):
        facet = 'facet'
        pivot = 'pivot'

        search = SolrSearch(None)
        search = search.pivot_by([pivot, facet], mincount=1)
        self.assertIn(pivot, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[pivot], {'mincount': 1})
        self.assertIn(facet, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[facet], {'mincount': 1})

        options = search.options()
        self.assertIn('facet.pivot', options)
        self.assertEqual(options['facet.pivot'], 'facet,pivot')

        # Equals True
        self.assertIn(pivot, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[pivot], {'mincount': 1})
        self.assertIn(facet, search.pivoter.fields)
        self.assertEqual(search.pivoter.fields[facet], {'mincount': 1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant