def test_returns_expected(self): project = factories.ProjectFactory() expected_urls = factories.URLFactory.create_batch(10, url_project=project) other_urls = factories.URLFactory.create_batch(10) json_url_list = url_handler.create_json_search(project.project_slug) for url in expected_urls: assert url.entity in json_url_list for url in other_urls: assert url.entity not in json_url_list
def search_json(request, slug): """Return a page with a JSON list of all URLs added to the specified project.""" json_string = create_json_search(slug) return HttpResponse(json_string, content_type='application/json')
def test_project_not_found(self): with pytest.raises(http.Http404): url_handler.create_json_search('fake_slug')