def test_search_func_deals_with_duplicate_search_terms(self): Search.objects.create(search_terms = 'atrazine') request = HttpRequest() request.method = 'POST' request.POST['search_terms'] = 'atrazine' request.POST['choice_field'] = '1' response = search(request) self.assertEqual(Search.objects.count(),1) self.assertEqual(response.status_code, 302)
def test_search_can_save_POST_and_create_Search_objects(self): request = HttpRequest() request.method = 'POST' request.POST['search_terms'] = 'atrazine missouri' request.POST['choice_field'] = '1' response = search(request) self.assertEqual(Search.objects.count(),1) newly_saved_search = Search.objects.first() self.assertEqual(newly_saved_search.search_terms, 'atrazine missouri')
def test_search_redirects_correctly_after_POST(self): request = HttpRequest() request.method = 'POST' search_terms = 'atrazine missouri' request.POST['search_terms'] = search_terms request.POST['choice_field'] = '1' search_terms_url ='atrazine_missouri_1' response = search(request) self.assertEqual(response.status_code, 302) self.assertEqual(response['location'],'/search/get_search_results/%s' % search_terms_url)