Coverage for articles/tests/test_urls.py: 93.75%
16 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-13 20:21 -0700
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-13 20:21 -0700
1import pytest 1a
2from django.urls import resolve, reverse 1a
4from .factories import ArticleFactory 1a
6pytestmark = pytest.mark.django_db 1a
9@pytest.fixture 1a
10def article(): 1a
11 return ArticleFactory()
14def test_article_list_reverse(): 1a
15 """article_list should reverse to /articles/."""
16 assert reverse("article_list") == "/articles/" 1a
19def test_article_list_resolve(): 1a
20 """/articles/" should resolve to article_list."""
21 assert resolve("/articles/").view_name == "article_list" 1a
24def test_article_add_reverse(): 1a
25 """article_new should reverse to /articles/new/."""
26 assert reverse("article_new") == "/articles/new/" 1a
29def test_article_add_resolve(): 1a
30 """/articles/new/" should resolve to article_new."""
31 assert resolve("/articles/new/").view_name == "article_new" 1a
34# TODO Revisit ArticleFactory() construction & build an appropriate slug to test
35""" 1a
36def test_article_detail_reverse(article):
37 # article_detail should reverse to /articles/uuid.
38 url = reverse("article_detail", kwargs={"pk": article.id})
39 assert url == f"/articles/{article.id}/"
42def test_article_detail_resolve(article):
43 # /articles/{article.id}/ should resolve to article_detail.
44 url = f"/articles/{article.id}/"
45 assert resolve(url).view_name == "article_detail"
46"""