예제 #1
0
파일: tests.py 프로젝트: scratchmex/doorman
 def test_index_200(self, client: Client):
     res = client.get("/")
     assertContains(res, "Doorman")
예제 #2
0
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')
예제 #3
0
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)
예제 #4
0
 def test_tagline(self, client, site, landing_page):
     """landingpage tagline should display"""
     response = client.get(landing_page.relative_url(site))
     assertContains(response, "tagline")
예제 #5
0
 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>")
예제 #6
0
def test_good_cheese_list_view_expanded(rf):
    request = rf.get(reverse("cheeses:list"))
    response = CheeseListView.as_view()(request)
    assertContains(response, 'Cheese List')
예제 #7
0
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")
예제 #8
0
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>')
예제 #9
0
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>')
예제 #10
0
    def test_valid_first_name(self):
        response = self.client.post(
            self.url, {"first_name": "contributor", "email": self.user.email}
        )

        assertContains(response, "Settings saved.")
예제 #11
0
def test_blog_list_view(rf):
    request = rf.get(reverse('blog:list'))
    response = PostListView.as_view()(request)
    assertContains(response, '<title>Blog</title>')
예제 #12
0
    def test_missing_profile_fields(self):
        response = self.client.post(self.url, {})

        assertContains(response, "This field is required.", count=2)
예제 #13
0
    def test_invalid_email(self):
        response = self.client.post(self.url, {"email": "usermail"})

        assertContains(response, "Enter a valid email address.")
예제 #14
0
    def test_invalid_first_name(self):
        response = self.client.post(self.url, {"first_name": '<aa>"\'"'})

        assertContains(response, "Enter a valid value.")
예제 #15
0
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)
예제 #16
0
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})
예제 #17
0
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')
예제 #18
0
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")
예제 #19
0
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')
예제 #20
0
def test_list(admin_client, case_1):
    response = admin_client.get("/cases")
    assertContains(response, "Cases")
예제 #21
0
def test_checkspage_content(client):
    response = client.get(reverse("checks:check"))
    assertContains(response, "Run a checkup on my site")
예제 #22
0
def test_case_not_found(admin_client):
    response = admin_client.get("/cases/1")
    assertContains(response, "Not Found", status_code=404)
예제 #23
0
 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)
예제 #24
0
def test_case(admin_client, case_1, complaint):
    response = admin_client.get(f"/cases/{case_1.id}")
    assertContains(response, "DIY")
예제 #25
0
 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.")
예제 #26
0
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")
예제 #27
0
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')
예제 #28
0
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)
예제 #29
0
def test_cheese_create_correct_title(client, user):
    client.force_login(user)
    response = client.get(reverse("cheeses:create"))
    assertContains(response, "Add Cheese")
예제 #30
0
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"))