Refactor handlers to be in their own classes for easier maintainability
This commit is contained in:
parent
d1ca60b779
commit
85f21e739d
19 changed files with 1826 additions and 1463 deletions
34
tests/test_base_handler.py
Normal file
34
tests/test_base_handler.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from jinjaturtle.handlers.base import BaseHandler
|
||||
|
||||
|
||||
def test_split_inline_comment_handles_quoted_hash():
|
||||
# The '#' inside quotes should not start a comment; the one outside should.
|
||||
text = " 'foo # not comment' # real"
|
||||
handler = BaseHandler()
|
||||
value, comment = handler._split_inline_comment(text, {"#"})
|
||||
assert "not comment" in value
|
||||
assert comment.strip() == "# real"
|
||||
|
||||
|
||||
def test_base_handler_abstract_methods_raise_not_implemented(tmp_path: Path):
|
||||
"""
|
||||
Ensure the abstract methods on BaseHandler all raise NotImplementedError.
|
||||
This covers the stub implementations.
|
||||
"""
|
||||
handler = BaseHandler()
|
||||
dummy_path = tmp_path / "dummy.cfg"
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
handler.parse(dummy_path)
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
handler.flatten(object())
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
handler.generate_template(parsed=object(), role_prefix="role")
|
||||
Loading…
Add table
Add a link
Reference in a new issue