예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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']
예제 #6
0
 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']