# 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
    assert '"/contacts/russia/web/public/"' in result
    assert '"/contacts/russia/web/private/"' in result

    context = template_context(request='/contacts/russia/web/')
    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{ALIAS_TRUNK}"', context)

    assert '"/users/moderators/"' in result
    assert '"/articles/cats/ugly/"' in result
    assert '"/home/"' in result
    assert '"/users/ordinary/"' in result
    assert '"/users/hidden/"' not in result

    assert 'class="current_item current_branch">Web' in result
    assert 'class="current_branch">Contacts' in result
    assert 'class="current_branch">Home' in result

    context = template_context(request='/articles/')
    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{ALIAS_THIS_CHILDREN}"', context)

    assert '"/articles/"' not in result
    assert '"/articles/cats/"' in result
    assert '"/articles/cats/ugly/"' in result
    assert '"/articles/mice/"' not in result  # inmenu False

    context = template_context(request='/articles/cats/bad/')
    result = template_render_tag(
        'sitetree', f'sitetree_menu from "mytree" include "{ALIAS_THIS_SIBLINGS}"', context)

    assert '"/articles/cats/"' not in result
    assert '"/articles/cats/good/"' in result

# 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

    assert '"/contacts/russia/web/public/"' in result
    assert '"/contacts/russia/web/private/"' in result

    context = template_context(request='/contacts/russia/web/')
    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{ALIAS_TRUNK}"', context)

    assert '"/users/moderators/"' in result
    assert '"/articles/cats/ugly/"' in result
    assert '"/home/"' in result
    assert '"/users/ordinary/"' in result
    assert '"/users/hidden/"' not in result

    assert 'class="current_item current_branch">Web' in result
    assert 'class="current_branch">Contacts' in result
    assert 'class="current_branch">Home' in result

    context = template_context(request='/articles/')
    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{ALIAS_THIS_CHILDREN}"', context)

    assert '"/articles/"' not in result
    assert '"/articles/cats/"' in result
    assert '"/articles/cats/ugly/"' in result
    assert '"/articles/mice/"' not in result  # inmenu False

    context = template_context(request='/articles/cats/bad/')
    result = template_render_tag(
        'sitetree', f'sitetree_menu from "mytree" include "{ALIAS_THIS_SIBLINGS}"', context)

    assert '"/articles/cats/"' not in result
    assert '"/articles/cats/good/"' in result

    assert '"/articles/cats/bad/"' in result