Add Docker-executed pytest suite with >90% coverage
This commit is contained in:
27
apps/blog/tests/test_more_models.py
Normal file
27
apps/blog/tests/test_more_models.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
|
||||
from apps.blog.models import TagMetadata
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_home_context_lists_articles(home_page, article_page):
|
||||
ctx = home_page.get_context(type("Req", (), {"GET": {}})())
|
||||
assert "latest_articles" in ctx
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_index_context_handles_page_values(article_index, article_page, rf):
|
||||
request = rf.get("/", {"page": "notanumber"})
|
||||
ctx = article_index.get_context(request)
|
||||
assert ctx["articles"].number == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_get_related_articles_fallback(article_page, article_index):
|
||||
related = article_page.get_related_articles()
|
||||
assert isinstance(related, list)
|
||||
|
||||
|
||||
def test_tag_metadata_fallback_classes():
|
||||
css = TagMetadata.get_fallback_css()
|
||||
assert css["bg"].startswith("bg-")
|
||||
Reference in New Issue
Block a user