def test_filter_data(self): api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') test_facility = mommy.make(Facility, name='test facility') index_instance(test_facility, 'test_index') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') # some weird bug there is a delay in getting the search results for x in range(0, 100): search_filter.filter(qs, 'test') api.delete_index('test_index')
def test_filter_data(self): api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') test_facility = mommy.make(Facility, name='test facility') index_instance( 'facilities', 'Facility', str(test_facility.id), 'test_index') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') # some weird bug there is a delay in getting the search results for x in range(0, 100): search_filter.filter(qs, 'test') api.delete_index('test_index')
def test_seach_facility_by_code(self): mommy.make(Facility, code=17780) api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') test_facility = mommy.make(Facility, name='test facility') index_instance('facilities', 'Facility', str(test_facility.id), 'test_index') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') # some weird bug there is a delay in getting the search results for x in range(0, 100): search_filter.filter(qs, 18990) search_filter.filter(qs, 17780) api.delete_index('test_index')
def test_filter_no_data(self): api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') mommy.make(Facility, name='test facility') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') result = search_filter.filter(qs, 'test') # no documents have been indexed self.assertEquals(result.count(), 0) api.delete_index('test_index')
def test_filter_elastic_not_available(self): with patch.object(ElasticAPI, 'search_document') as mock_search: mock_search.return_value = None api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') mommy.make(Facility, name='test facility') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') result = search_filter.filter(qs, 'test') # no documents have been indexed self.assertEquals(result.count(), 0) api.delete_index('test_index')
def test_filter_elastic_not_available(self): with patch.object( ElasticAPI, 'search_document') as mock_search: mock_search.return_value = None api = ElasticAPI() api.delete_index('test_index') api.setup_index('test_index') mommy.make(Facility, name='test facility') mommy.make(Facility) qs = Facility.objects.all() search_filter = SearchFilter(name='search') result = search_filter.filter(qs, 'test') # no documents have been indexed self.assertEquals(result.count(), 0) api.delete_index('test_index')