59 lines
1.2 KiB
Python
59 lines
1.2 KiB
Python
"""Tests associated to the models"""
|
|
|
|
from jack.models import Article, Section, Site
|
|
|
|
content = """---
|
|
title: This is a test article
|
|
description: Some fancy description
|
|
tags:
|
|
- python
|
|
- dev
|
|
- code
|
|
writers: ["Ken Follet", "Gilles Legardinier"]
|
|
---
|
|
|
|
This is the content
|
|
|
|
```python
|
|
def this_is_a_python_function():
|
|
...
|
|
```
|
|
|
|
"""
|
|
|
|
def test_article_metadata():
|
|
article = Article(content, None)
|
|
assert article.title == "This is a test article"
|
|
assert article.description == "Some fancy description"
|
|
assert article.tags == ["python", "dev", "code"]
|
|
|
|
|
|
def test_article_content():
|
|
article = Article(content, None)
|
|
assert "title" not in article.content
|
|
|
|
|
|
def test_article_published_date():
|
|
article = Article(content, None)
|
|
assert article.published_date is None
|
|
|
|
|
|
def test_article_fenced_code():
|
|
article = Article(content, None)
|
|
assert """<pre><code class="language-python">""" in article.to_prose()
|
|
|
|
|
|
def test_article_sections():
|
|
article = Article(content, "a/b/c")
|
|
assert article.sections == ["a", "b"]
|
|
|
|
|
|
def test_site_append_article():
|
|
site = Site(".")
|
|
article = Article(content, None)
|
|
site.add(article)
|
|
|
|
assert article in site.articles
|
|
assert "python" in site.tags
|
|
assert article in site.tags.get("python")
|