def test_school_search_api(self, mock_sqs_autocomplete): """school_search_api should return json.""" mock_school = School.objects.get(pk=155317) # mock the solr returned value solr_school = self.SolrSchool() solr_school.text = mock_school.primary_alias solr_school.school_id = mock_school.school_id solr_school.city = mock_school.city solr_school.state = mock_school.state solr_queryset = [solr_school] mock_sqs_autocomplete.return_value = solr_queryset url = "%s?q=Kansas" % reverse('disclosures:school_search') request = RequestFactory().get(url) resp = school_search_api(request) self.assertTrue('Kansas' in resp.content) self.assertTrue('155317' in resp.content)
def test_school_search_api(self, mock_autocomplete): """school_search_api should return json.""" school = School.objects.get(pk=155317) # mock the search returned value elastic_school = self.ElasticSchool() elastic_school.text = school.primary_alias elastic_school.school_id = school.school_id elastic_school.city = school.city elastic_school.state = school.state elastic_school.nicknames = "Jayhawks" mock_autocomplete.return_value = [elastic_school] url = "{}?q=Kansas".format( reverse("paying_for_college:disclosures:school_search")) response = school_search_api(RequestFactory().get(url)) self.assertTrue(b"Kansas" in response.content) self.assertTrue(b"155317" in response.content) self.assertTrue(b"Jayhawks" in response.content)
def test_school_search_api(self, mock_sqs_autocomplete): """school_search_api should return json.""" mock_school = School.objects.get(pk=155317) # mock the search returned value elastic_school = self.ElasticSchool() elastic_school.text = mock_school.primary_alias elastic_school.school_id = mock_school.school_id elastic_school.city = mock_school.city elastic_school.state = mock_school.state elastic_school.nicknames = 'Jayhawks' solr_queryset = [elastic_school] mock_sqs_autocomplete.return_value = solr_queryset url = "%s?q=Kansas" % reverse('disclosures:school_search') request = RequestFactory().get(url) resp = school_search_api(request) self.assertTrue(b'Kansas' in resp.content) self.assertTrue(b'155317' in resp.content) self.assertTrue(b'Jayhawks' in resp.content)