summaryrefslogtreecommitdiffstats
path: root/tests/test_models.py
blob: 858ce21b215ccad17bce7a0e6b49c8bd5d30a048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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