File: test_config.py

package info (click to toggle)
mkdocs-static-i18n 1.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,412 kB
  • sloc: python: 3,131; xml: 45; makefile: 21; sh: 17
file content (42 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download
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
from mkdocs.config.base import load_config

from mkdocs_static_i18n.plugin import I18n


def test_plugin_single_language_en():
    plugin = I18n()
    plugin.load_config({"languages": [{"locale": "en", "name": "english", "default": True}]})
    config = load_config(
        "tests/mkdocs.yml",
        theme={"name": "mkdocs"},
        use_directory_urls=True,
        docs_dir="docs_suffix_structure_one_language/",
    )
    result = plugin.on_config(config)
    assert str(result["theme"]["locale"]) == "en"


def test_plugin_single_language_fr():
    plugin = I18n()
    plugin.load_config({"languages": [{"locale": "fr", "name": "français", "default": True}]})
    config = load_config(
        "tests/mkdocs.yml",
        theme={"name": "mkdocs"},
        use_directory_urls=True,
        docs_dir="docs_suffix_structure_one_language/",
    )
    result = plugin.on_config(config)
    assert str(result["theme"]["locale"]) == "fr"


def test_plugin_theme_sitemap():
    plugin = I18n()
    plugin.load_config({"languages": [{"locale": "fr", "name": "français", "default": True}]})
    config = load_config(
        "tests/mkdocs.yml",
        theme={"name": "mkdocs"},
        use_directory_urls=True,
        docs_dir="docs_suffix_structure_one_language/",
    )
    result = plugin.on_config(config)
    assert result["theme"].dirs[0].endswith("custom_i18n_sitemap")