def test_cannot_add_a_search_if_the_results_count_is_not_provided(self): # Setup request = self.factory.post('/', {'querystring': 'foo=bar&xyz=test'}) request.user = AnonymousUser() SessionMiddleware().process_request(request) view = SavedSearchAddView.as_view() # Run view(request) # Check searches = SavedSearchList(request) assert not len(searches)
def test_cannot_add_a_search_if_the_querystring_is_not_a_valid_querystring(self): # Setup request = self.factory.post('/', {'querystring': 'bad', 'results_count': 100}) request.user = AnonymousUser() SessionMiddleware().process_request(request) view = SavedSearchAddView.as_view() # Run view(request) # Check searches = SavedSearchList(request) assert not len(searches)
def test_cannot_add_a_search_if_the_querystring_is_not_a_valid_querystring( self): # Setup request = self.factory.post('/', { 'querystring': 'bad', 'results_count': 100 }) request.user = AnonymousUser() SessionMiddleware().process_request(request) view = SavedSearchAddView.as_view() # Run view(request) # Check searches = SavedSearchList(request) assert not len(searches)
def test_can_add_a_search_to_the_list_of_saved_searches(self): # Setup request = self.factory.post('/', {'querystring': 'foo=bar&xyz=test', 'results_count': 100}) request.user = AnonymousUser() SessionMiddleware().process_request(request) view = SavedSearchAddView.as_view() # Run response = view(request) # Check assert response.status_code == 200 searches = SavedSearchList(request) assert len(searches) == 1 assert searches[0]['querystring'] == 'foo=bar&xyz=test' assert searches[0]['results_count'] == 100 assert searches[0]['uuid'] assert searches[0]['timestamp']
def test_can_add_a_search_to_the_list_of_saved_searches(self): # Setup request = self.factory.post('/', { 'querystring': 'foo=bar&xyz=test', 'results_count': 100 }) request.user = AnonymousUser() SessionMiddleware().process_request(request) view = SavedSearchAddView.as_view() # Run response = view(request) # Check assert response.status_code == 200 searches = SavedSearchList(request) assert len(searches) == 1 assert searches[0]['querystring'] == 'foo=bar&xyz=test' assert searches[0]['results_count'] == 100 assert searches[0]['uuid'] assert searches[0]['timestamp']