def test_index_200(self, client: Client): res = client.get("/") assertContains(res, "Doorman")
def test_coffee_create_correct_title(rf, admin_user): """Page title for CoffeeCreateView should be Add Coffee.""" request = rf.get(reverse('coffee:add')) request.user = admin_user response = CoffeeCreateView.as_view()(request) assertContains(response, 'Add Coffee')
def test_good_cheese_detail_view(rf, cheese): url = reverse("cheeses:detail", kwargs={'slug': cheese.slug}) request = rf.get(url) callable_obj = CheeseDetailView.as_view() response = callable_obj(request, slug=cheese.slug) assertContains(response, cheese.name)
def test_tagline(self, client, site, landing_page): """landingpage tagline should display""" response = client.get(landing_page.relative_url(site)) assertContains(response, "tagline")
def test_page_content(self, client, site, content_page): """contentpage editable content should display""" response = client.get(content_page.relative_url(site)) assertContains(response, "<p>content of the content page</p>")
def test_good_cheese_list_view_expanded(rf): request = rf.get(reverse("cheeses:list")) response = CheeseListView.as_view()(request) assertContains(response, 'Cheese List')
def test_aliments(client, db, create_user, test_password): """test eponym function""" client.login(username=create_user.username, password=test_password) response = client.get("/aliments/") assert response.status_code == 200 assertContains(response, "chocolate")
def test_blog_create_view(client, user): url = reverse('blog:add') client.force_login(user) response = client.get(url) assert response.status_code == 200 assertContains(response, '<h3>Add Post</h3>')
def test_blog_update_view(client, user, post): client.force_login(user) url = reverse('blog:update', kwargs={'slug': post.slug}) response = client.get(url) assertContains(response, '<h3>Update Post</h3>')
def test_valid_first_name(self): response = self.client.post( self.url, {"first_name": "contributor", "email": self.user.email} ) assertContains(response, "Settings saved.")
def test_blog_list_view(rf): request = rf.get(reverse('blog:list')) response = PostListView.as_view()(request) assertContains(response, '<title>Blog</title>')
def test_missing_profile_fields(self): response = self.client.post(self.url, {}) assertContains(response, "This field is required.", count=2)
def test_invalid_email(self): response = self.client.post(self.url, {"email": "usermail"}) assertContains(response, "Enter a valid email address.")
def test_invalid_first_name(self): response = self.client.post(self.url, {"first_name": '<aa>"\'"'}) assertContains(response, "Enter a valid value.")
def test_get_route_garmin_activity_url(athlete, client, gpx_route): gpx_route.garmin_id = 123456 gpx_route.save(update_fields=["garmin_id"]) response = client.get(gpx_route.get_absolute_url()) assertContains(response, gpx_route.garmin_activity_url)
def test_reassign_view(admin_client, case_1, staff_user_2): response = admin_client.get(f"/cases/{case_1.id}/reassign") assertContains(response, "staffuser2") response = admin_client.post(f"/cases/{case_1.id}/reassign", {"assigned": 0}) assertContains(response, "valid choice") admin_client.post(f"/cases/{case_1.id}/reassign", {"assigned": staff_user_2.id})
def test_cheese_create_correct_title(rf, admin_user): """Заголовок страницы для CheeseCreateView должен быть «Add Cheese».""" request = rf.get(reverse('cheeses:add')) request.user = admin_user response = CheeseCreateView.as_view()(request) assertContains(response, 'Add Cheese')
def test_merging_cases(admin_client, case_1, case_other_uprn, action_types): response = admin_client.post( f"/cases/{case_other_uprn.id}/merge", {"stop": 1}, follow=True ) assertNotContains(response, "We have forgotten your current merging.") response = admin_client.post(f"/cases/{case_other_uprn.id}/merge") assertContains(response, "visit the case you wish to merge") response = admin_client.get(f"/cases/{case_1.id}") assertContains(response, f"Merge #{case_other_uprn.id} into this case") response = admin_client.post( f"/cases/{case_other_uprn.id}/merge", {"stop": 1}, follow=True ) assertContains(response, "We have forgotten your current merging.") assertNotContains(response, "Merge #{case_other_uprn.id} into this case") response = admin_client.post(f"/cases/{case_other_uprn.id}/merge") response = admin_client.post(f"/cases/{case_1.id}/merge", {"dupe": 1}) assertContains(response, "has been merged into") a = Action.objects.create(case=case_1, notes="Internal note", type=action_types[1]) response = admin_client.get(f"/cases/{case_other_uprn.id}") assertContains(response, "This case has been merged into") assertContains(response, "Noise witnessed")
def test_cheese_create_correct_title(rf, admin_user): request = rf.get(reverse('cheeses:add')) request.user = admin_user response = CheeseCreateView.as_view()(request) assertContains(response, 'Add Cheese')
def test_list(admin_client, case_1): response = admin_client.get("/cases") assertContains(response, "Cases")
def test_checkspage_content(client): response = client.get(reverse("checks:check")) assertContains(response, "Run a checkup on my site")
def test_case_not_found(admin_client): response = admin_client.get("/cases/1") assertContains(response, "Not Found", status_code=404)
def test_page_content(self, client, site, homepage): """homepage editable content should display""" response = client.get(homepage.get_url()) assertTemplateUsed(response, "cdhpages/home_page.html") assertContains(response, homepage.body[0].value.source)
def test_case(admin_client, case_1, complaint): response = admin_client.get(f"/cases/{case_1.id}") assertContains(response, "DIY")
def test_empty_events(self, client, site, homepage): """homepage should display message when no events are available""" response = client.get(homepage.relative_url(site)) assertTemplateNotUsed(response, "events/snippets/event_card.html") assertContains(response, "Next semester's events are being scheduled.")
def test_case_uprn(admin_client, case_other_uprn): response = admin_client.get(f"/cases/{case_other_uprn.id}") assertContains(response, "Wombat") assertContains(response, "Flat 4, 2 Example Road")
def test_good_cheese_list_view_expanded(rf): url = reverse('cheeses:list') request = rf.get(url) callable_obj = CheeseListView.as_view() response = callable_obj(request) assertContains(response, 'Cheese List')
def test_get_route_garmin_upload_url(athlete, client, gpx_route): response = client.get(gpx_route.get_absolute_url()) user = response.context["user"] assert user.has_perm(gpx_route.get_perm("garmin_upload"), gpx_route) assertContains(response, gpx_route.garmin_upload_url)
def test_cheese_create_correct_title(client, user): client.force_login(user) response = client.get(reverse("cheeses:create")) assertContains(response, "Add Cheese")
def test_get_gpx_route_no_update_button(athlete, client): route = RouteFactory(data_source="homebytwo", athlete=athlete) response = client.get(route.get_absolute_url()) assertContains(response, route.edit_url) assertNotContains(response, route.get_absolute_url("update"))