# 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 result == ''
    assert context.get('somevar') == target_url


def test_sitetree_menu(template_render_tag, template_context, common_tree):

    result = template_render_tag(
        'sitetree', f'sitetree_menu from "notree" include "{ALIAS_TRUNK}"', template_context())  # non-existing tree

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

    with pytest.raises(TemplateSyntaxError):
        template_render_tag('sitetree', 'sitetree_menu')

    item_ruweb = common_tree['/contacts/russia/web/']

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

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

    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{item_ruweb.id}"', context)

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

    context = template_context(request='/contacts/russia/web/')

# 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 result == ''
    assert context.get('somevar') == target_url


def test_sitetree_menu(template_render_tag, template_context, common_tree):

    result = template_render_tag(
        'sitetree', f'sitetree_menu from "notree" include "{ALIAS_TRUNK}"', template_context())  # non-existing tree

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

    with pytest.raises(TemplateSyntaxError):
        template_render_tag('sitetree', 'sitetree_menu')

    item_ruweb = common_tree['/contacts/russia/web/']

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

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

    result = template_render_tag('sitetree', f'sitetree_menu from "mytree" include "{item_ruweb.id}"', context)

    assert '"/contacts/russia/web/"' not in result
    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)