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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
from __future__ import annotations
import os
from unittest import TestCase
from . import utils as test_utils
class TestRst(test_utils.MockSiteTestMixin, TestCase):
def test_simple(self):
self.maxDiff = None
files = {
"taxonomies/tags.taxonomy": {},
"index.rst": """
:date: 2016-04-16 10:23:00+02:00
:tags: [example, "another_tag"]
:description:
line1
line2
line3
Example blog post in reStructuredText
=====================================
""",
}
with self.site(files) as mocksite:
mocksite.assertPagePaths(
(
"",
"taxonomies",
"taxonomies/tags",
"taxonomies/tags/example",
"taxonomies/tags/example/index.rss",
"taxonomies/tags/example/index.atom",
"taxonomies/tags/example/archive",
"taxonomies/tags/another_tag",
"taxonomies/tags/another_tag/index.rss",
"taxonomies/tags/another_tag/index.atom",
"taxonomies/tags/another_tag/archive",
)
)
page, tags, tag_example, tag_another = mocksite.page(
"",
"taxonomies/tags",
"taxonomies/tags/example",
"taxonomies/tags/another_tag",
)
# We have a root dir index and dir indices for all subdirs
self.assertEqual(page.TYPE, "rst")
self.assertCountEqual(page.tags, [tag_example, tag_another])
self.assertEqual(
page.to_dict(),
{
"src": {
"abspath": os.path.join(
mocksite.site.content_root, "index.rst"
),
"relpath": "index.rst",
},
"site_path": "",
"build_path": "index.html",
"meta": {
"author": "Test User",
"copyright": "© 2016 Test User",
"date": "2016-04-16 10:23:00+02:00",
"draft": False,
"syndicated": True,
"syndication_date": "2016-04-16 10:23:00+02:00",
"description": "line1\nline2\nline3",
"tags": [
"CategoryPage(taxonomies/tags/example)",
"CategoryPage(taxonomies/tags/another_tag)",
],
"template": "page.html",
"template_copyright": "compiled:None",
"title": "Example blog post in reStructuredText",
"indexed": True,
"nav": [],
"site_name": "Test site",
"site_url": "https://www.example.org",
"related": {},
},
"type": "rst",
},
)
|