Adding upstream version 0.45+dfsg.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
b4efa209be
commit
eb42e29864
35 changed files with 4489 additions and 0 deletions
88
tests/test_catalog.py
Normal file
88
tests/test_catalog.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
import pytest
|
||||
|
||||
import jinjax
|
||||
|
||||
|
||||
def test_add_folder_with_default_prefix():
|
||||
catalog = jinjax.Catalog()
|
||||
catalog.add_folder("file_path")
|
||||
|
||||
assert "file_path" in catalog.prefixes[""].searchpath
|
||||
|
||||
|
||||
def test_add_folder_with_custom_prefix():
|
||||
catalog = jinjax.Catalog()
|
||||
catalog.add_folder("file_path", prefix="custom")
|
||||
|
||||
assert "file_path" in catalog.prefixes["custom"].searchpath
|
||||
|
||||
|
||||
def test_add_folder_with_dirty_prefix():
|
||||
catalog = jinjax.Catalog()
|
||||
catalog.add_folder("file_path", prefix="/custom.")
|
||||
|
||||
assert "/custom." not in catalog.prefixes
|
||||
assert "file_path" in catalog.prefixes["custom"].searchpath
|
||||
|
||||
|
||||
def test_add_folders_with_same_prefix():
|
||||
catalog = jinjax.Catalog()
|
||||
catalog.add_folder("file_path1", prefix="custom")
|
||||
catalog.add_folder("file_path2", prefix="custom")
|
||||
|
||||
assert "file_path1" in catalog.prefixes["custom"].searchpath
|
||||
assert "file_path2" in catalog.prefixes["custom"].searchpath
|
||||
|
||||
|
||||
def test_add_same_folder_in_same_prefix_does_nothing():
|
||||
catalog = jinjax.Catalog()
|
||||
catalog.add_folder("file_path", prefix="custom")
|
||||
catalog.add_folder("file_path", prefix="custom")
|
||||
|
||||
assert catalog.prefixes["custom"].searchpath.count("file_path") == 1
|
||||
|
||||
|
||||
def test_add_module_legacy():
|
||||
class Module:
|
||||
components_path = "legacy_path"
|
||||
prefix = "legacy"
|
||||
|
||||
catalog = jinjax.Catalog()
|
||||
module = Module()
|
||||
catalog.add_module(module)
|
||||
|
||||
assert "legacy_path" in catalog.prefixes["legacy"].searchpath
|
||||
|
||||
|
||||
def test_add_module_legacy_with_default_prefix():
|
||||
class Module:
|
||||
components_path = "legacy_path"
|
||||
|
||||
catalog = jinjax.Catalog()
|
||||
module = Module()
|
||||
catalog.add_module(module)
|
||||
|
||||
assert "legacy_path" in catalog.prefixes[""].searchpath
|
||||
|
||||
|
||||
def test_add_module_legacy_with_custom_prefix():
|
||||
class Module:
|
||||
components_path = "legacy_path"
|
||||
prefix = "legacy"
|
||||
|
||||
catalog = jinjax.Catalog()
|
||||
module = Module()
|
||||
catalog.add_module(module, prefix="custom")
|
||||
|
||||
assert "legacy" not in catalog.prefixes
|
||||
assert "legacy_path" in catalog.prefixes["custom"].searchpath
|
||||
|
||||
|
||||
def test_add_module_fails_with_other_modules():
|
||||
class Module:
|
||||
pass
|
||||
|
||||
catalog = jinjax.Catalog()
|
||||
module = Module()
|
||||
with pytest.raises(AttributeError):
|
||||
catalog.add_module(module)
|
Loading…
Add table
Add a link
Reference in a new issue