Ejemplo n.º 1
0
 def test_fail_reverse_invalid_url(self):
     with self.assertRaises(NoReverseMatch):
         page_reverse("/")
Ejemplo n.º 2
0
 def test_call_template_with_error_and_debug_disabled(self):
     Page.objects.create(slug="buggy-template", template_name="buggy-template.html")
     response = self.client.get(page_reverse("buggy-template"))
     self.assertStatusCode(response, 404)  # original error is 404 because we dont map pages urls
Ejemplo n.º 3
0
 def test_success_reverse(self):
     Page.objects.create(slug="about", template_name="about.html")
     url = page_reverse("about")
     self.assertEquals("/about/", url)
Ejemplo n.º 4
0
 def test_fail_reverse_missing_page(self):
     with self.assertRaises(NoReverseMatch):
         page_reverse("unknown")
Ejemplo n.º 5
0
def page_url(slug):
    return page_reverse(slug)
Ejemplo n.º 6
0
def test_call_template_with_error_and_debug_disabled(client):
    Page.objects.create(slug="buggy-template",
                        template_name="buggy-template.html")
    response = client.get(page_reverse("buggy-template"))
    assert response.status_code == 404  # original error is 404 because we dont map pages urls
Ejemplo n.º 7
0
def test_fail_reverse_invalid_url():
    with pytest.raises(NoReverseMatch):
        page_reverse("/")
Ejemplo n.º 8
0
def test_fail_reverse_missing_page():
    with pytest.raises(NoReverseMatch):
        page_reverse("unknown")
Ejemplo n.º 9
0
def test_success_reverse():
    Page.objects.create(slug="about", template_name="about.html")
    url = page_reverse("about")
    assert "/about/" == url