import pytest 

from kheops.utils import *


@pytest.mark.parametrize(    
        "result,args,kwargs",
        [        
            (
                    ['this', 'this/is', 'this/is/my', 'this/is/my/hierarchy'],
                    ['this/is/my/hierarchy'],
                    {
                        'reverse': False,
                        'sep': '/',
                        'start_index': 0,
                    },
            ),
            (
                    ['this/is/my', 'this/is/my/hierarchy'],
                    ['this/is/my/hierarchy'],
                    {
                        'reverse': False,
                        'sep': '/',
                        'start_index': 3,
                    },
            ),
            (
                    ['hierarchy', 'hierarchy/my', 'hierarchy/my/is', 'hierarchy/my/is/this'],
                    ['this/is/my/hierarchy'],
                    {
                        'reverse': True,
                        'sep': '/',
                        'start_index': 0,
                    },
            ),
            (
                    ['this', 'this/is', 'this/is/my', 'this/is/my/server', 'this/is/my/server/domaine'],
                    ['this.is.my.server.domaine'],
                    {
                        'reverse': False,
                        'sep': '.',
                        'start_index': 0,
                    },
            ),
        ]
        )

def test_path_assemble_hier2(result, args, kwargs):

        res = path_assemble_hier(*args, **kwargs)
        assert result == res


@pytest.mark.parametrize(    
        "result,args",
        [        
            (
                'hello super world',
                ['hello {{ world }}', {'world': 'super world'}]
            )
        ]
        )
def test_render_template(result, args):

    res = render_template(*args)
    assert res == result


