# Path: sitetree/exceptions.py
# class SiteTreeError(Exception):
#     """Exception class for sitetree application."""
# 
# Path: sitetree/settings.py
# ALIAS_THIS_ANCESTOR_CHILDREN = 'this-ancestor-children'
# 
# ALIAS_THIS_CHILDREN = 'this-children'
# 
# ALIAS_THIS_PARENT_SIBLINGS = 'this-parent-siblings'
# 
# ALIAS_THIS_SIBLINGS = 'this-siblings'
# 
# ALIAS_TRUNK = 'trunk'


import pytest
from django.template.base import TemplateSyntaxError
from django.utils.translation import activate, deactivate_all
from sitetree.exceptions import SiteTreeError
from sitetree.settings import ALIAS_THIS_ANCESTOR_CHILDREN, ALIAS_THIS_CHILDREN, ALIAS_THIS_PARENT_SIBLINGS, \
    ALIAS_THIS_SIBLINGS, ALIAS_TRUNK
    from sitetree.toolbox import register_items_hook
    from sitetree.toolbox import register_i18n_trees
    from sitetree.models import TreeItem
    result = template_render_tag('sitetree', 'sitetree_breadcrumbs from "mytree"', template_context())

    assert result.strip() == '<ul>\n\t\n</ul>'

    context = template_context(request='/contacts/russia/web/private/')
    result = template_render_tag('sitetree', 'sitetree_breadcrumbs from "mytree"', context)

    assert '"/contacts/russia/web/"' in result
    assert '"/contacts/russia/"' in result
    assert '"/contacts/"' not in result  # inbreadcrumbs False
    assert '"/home/"' in result


def check_page_attr_tag(realm, value, settings, monkeypatch, template_render_tag, template_context):

    with pytest.raises(TemplateSyntaxError):  # Invalid tag arguments.
        template_render_tag('sitetree', f'sitetree_page_{realm}')

    context = template_context(request='/contacts/russia/')
    result = template_render_tag('sitetree', f'sitetree_page_{realm} from "mytree"', context)

    assert result == value

    result = template_render_tag('sitetree', f'sitetree_page_{realm} from "mytree" as somevar', context)

    assert result == ''
    assert context.get('somevar') == value

    settings.DEBUG = True


# Path: sitetree/exceptions.py
# class SiteTreeError(Exception):
#     """Exception class for sitetree application."""
# 
# Path: sitetree/settings.py
# ALIAS_THIS_ANCESTOR_CHILDREN = 'this-ancestor-children'
# 
# ALIAS_THIS_CHILDREN = 'this-children'
# 
# ALIAS_THIS_PARENT_SIBLINGS = 'this-parent-siblings'
# 
# ALIAS_THIS_SIBLINGS = 'this-siblings'
# 
# ALIAS_TRUNK = 'trunk'


# Path: sitetree/tests/test_templatetags.py
import pytest
from django.template.base import TemplateSyntaxError
from django.utils.translation import activate, deactivate_all
from sitetree.exceptions import SiteTreeError
from sitetree.settings import ALIAS_THIS_ANCESTOR_CHILDREN, ALIAS_THIS_CHILDREN, ALIAS_THIS_PARENT_SIBLINGS, \
    ALIAS_THIS_SIBLINGS, ALIAS_TRUNK
    from sitetree.toolbox import register_items_hook
    from sitetree.toolbox import register_i18n_trees
    from sitetree.models import TreeItem

    result = template_render_tag('sitetree', 'sitetree_breadcrumbs from "mytree"', template_context())

    assert result.strip() == '<ul>\n\t\n</ul>'

    context = template_context(request='/contacts/russia/web/private/')
    result = template_render_tag('sitetree', 'sitetree_breadcrumbs from "mytree"', context)

    assert '"/contacts/russia/web/"' in result
    assert '"/contacts/russia/"' in result
    assert '"/contacts/"' not in result  # inbreadcrumbs False
    assert '"/home/"' in result


def check_page_attr_tag(realm, value, settings, monkeypatch, template_render_tag, template_context):

    with pytest.raises(TemplateSyntaxError):  # Invalid tag arguments.
        template_render_tag('sitetree', f'sitetree_page_{realm}')

    context = template_context(request='/contacts/russia/')
    result = template_render_tag('sitetree', f'sitetree_page_{realm} from "mytree"', context)

    assert result == value

    result = template_render_tag('sitetree', f'sitetree_page_{realm} from "mytree" as somevar', context)

    assert result == ''
    assert context.get('somevar') == value

    settings.DEBUG = True


    with pytest.raises(SiteTreeError) as e: