summaryrefslogtreecommitdiffstats
path: root/tests/test_models.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-01 12:47:22 +0200
committerDanilo M. <danix@danix.xyz>2026-05-01 12:47:22 +0200
commitba5438abaa430358eeb69b1376737ce61a3d68dc (patch)
tree581baba65edf59a60ee6a069d381a747d123f6b4 /tests/test_models.py
parentaec3c628fb6196dd2d3cbfba84fe70a66c727833 (diff)
downloadpublisher-ba5438abaa430358eeb69b1376737ce61a3d68dc.tar.gz
publisher-ba5438abaa430358eeb69b1376737ce61a3d68dc.zip
feat: Article dataclass and ARTICLE_TYPES
Diffstat (limited to 'tests/test_models.py')
-rw-r--r--tests/test_models.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_models.py b/tests/test_models.py
new file mode 100644
index 0000000..858ce21
--- /dev/null
+++ b/tests/test_models.py
@@ -0,0 +1,36 @@
+from pathlib import Path
+from core.models import Article, ARTICLE_TYPES
+
+
+def test_article_types_contains_five():
+ assert len(ARTICLE_TYPES) == 5
+ assert "Tech" in ARTICLE_TYPES
+ assert "Life" in ARTICLE_TYPES
+
+
+def test_article_fields():
+ a = Article(
+ slug="test-post",
+ lang="it",
+ path=Path("/blog/content/it/articles/test-post/index.md"),
+ frontmatter={"title": "Test", "type": "Tech"},
+ has_translation=False,
+ translation_path=None,
+ )
+ assert a.slug == "test-post"
+ assert a.lang == "it"
+ assert a.has_translation is False
+ assert a.translation_path is None
+
+
+def test_article_with_translation():
+ a = Article(
+ slug="test-post",
+ lang="it",
+ path=Path("/blog/content/it/articles/test-post/index.md"),
+ frontmatter={},
+ has_translation=True,
+ translation_path=Path("/blog/content/en/articles/test-post/index.md"),
+ )
+ assert a.has_translation is True
+ assert a.translation_path is not None