Exemplo n.º 1
0
 def test_count_with_query_kwarg_containing_boolean_value(self):
     self._make_entry(name='one', foo=True)
     self._make_entry(name='two', foo=True)
     self._make_entry(name='three', foo=False)
     h.clean_and_reindex_solr()
     count = logic.entry.count(foo=True)
     h.assert_equal(count, 2)
Exemplo n.º 2
0
 def test_facets_with_query_kwarg_containing_boolean_value(self):
     self._make_entry(name='one', foo=True)
     self._make_entry(name='two', foo=True)
     self._make_entry(name='three', foo=False)
     h.clean_and_reindex_solr()
     facets = logic.entry.facets_for_fields(['name'], foo=True)
     h.assert_equal(facets, {u'name': {u'one': 1,
                                       u'two': 1}})
Exemplo n.º 3
0
    def test_count_with_query(self):
        self._make_entry(name='one', region="A")
        self._make_entry(name='two', region="A")
        self._make_entry(name='three', region="B")
        self._make_entry(name='four')
        h.clean_and_reindex_solr()

        count = logic.entry.count(region="A")
        h.assert_equal(count, 2)
Exemplo n.º 4
0
    def test_facets_with_query_kwarg(self):
        self._make_entry(name='one', region="RegionA")
        self._make_entry(name='two', region="RegionA")
        self._make_entry(name='three', region="Region B")
        h.clean_and_reindex_solr()

        facets = logic.entry.facets_for_fields(['name'], region=u'RegionA')
        h.assert_equal(facets, {u'name': {u'one': 1,
                                          u'two': 1}})
Exemplo n.º 5
0
    def test_count_with_dataset_name(self):
        self._make_entry(name='one')
        self._make_entry(name='two')
        other_dataset = self._make_dataset('other_dataset')
        self._make_entry(name='three', dataset=other_dataset)
        self._make_entry(name='four', dataset=other_dataset)
        h.clean_and_reindex_solr()

        count = logic.entry.count(dataset_name='other_dataset')
        h.assert_equal(count, 2)
Exemplo n.º 6
0
 def test_facets(self):
     self._make_entry(name='one', region="Region A")
     self._make_entry(name='two', region="Region A")
     self._make_entry(name='three', region="Region B")
     h.clean_and_reindex_solr()
     facets = logic.entry.facets_for_fields(['name', 'region'])
     h.assert_equal(facets, {u'name': {u'one': 1,
                                       u'two': 1,
                                       u'three': 1},
                             u'region': {'Region A': 2,
                                         'Region B': 1}})
Exemplo n.º 7
0
    def test_facets_with_query_kwarg_and_space(self):
        self._make_entry(name='one', region="Region A")
        self._make_entry(name='two', region="Region A")
        self._make_entry(name='three', region="Region B")
        h.clean_and_reindex_solr()

        facets = logic.entry.facets_for_fields(['name'], region='Region A')

        h.skip("This test has been failing for a long time, commented out. "\
               "Skipping to register known failure that needs fixing eventually.")
        h.assert_equal(facets, {u'name': {u'one': 1,
                                          u'two': 1}})
Exemplo n.º 8
0
    def test_facets_fail_for_solr_textgen_fields(self):
        # facets for a solr field return facets for the tokens stored
        # in the field. Depending on the type this may mean that
        # it's not the string stored in the field, but tokens after
        # splitting, stemming or lowercasing
        self._make_entry(name='one', description="Description One")
        self._make_entry(name='two', description="Description Two")
        h.clean_and_reindex_solr()
        facets = logic.entry.facets_for_fields(['description'])

        # The result is not ["Description One", "Description Two"]
        h.assert_equal(facets, {u'description': {u'description': 2,
                                                   u'two': 1,
                                                   u'one': 1}})
Exemplo n.º 9
0
    def test_facets_by_dataset(self):
        self._make_entry(name='one')
        self._make_entry(name='two')
        other_dataset = self._make_dataset('other_dataset')
        self._make_entry(name='three', dataset=other_dataset)
        self._make_entry(name='four', dataset=other_dataset)
        h.clean_and_reindex_solr()
        # without a dataset_name it returns the distincts across all datasets
        facets = logic.entry.facets_for_fields(['name'])
        h.assert_equal(facets, {u'name': {u'one': 1,
                                          u'two': 1,
                                          u'three': 1,
                                          u'four': 1}})

        # we can limit it with dataset_name
        facets = logic.entry.facets_for_fields(['name'],
                                               dataset_name='other_dataset')

        h.assert_equal(facets, {u'name': {u'three': 1,
                                          u'four': 1}})