Exemplo n.º 1
0
def test_find_path_in_tree_will_convert_path_ending_in_index_html_to_directory():
    tree = {
        "url": "/",
        "children": [
            {
                "url": "/projects/",
                "children": [
                    {"url": "/projects/funk/"},
                    {"url": "/projects/zuice/"}
                ]
            },
            {"url": "/blog/"}
        ]
    }
    assert_equals([0, 0, 1], find_path_in_tree(tree, "/projects/zuice/index.html"))
Exemplo n.º 2
0
def test_find_path_in_tree_returns_list_of_indices_to_path():
    tree = {
        "url": "/",
        "children": [
            {
                "url": "/projects/",
                "children": [
                    {"url": "/projects/funk/"},
                    {"url": "/projects/zuice/"}
                ]
            },
            {"url": "/blog/"}
        ]
    }
    assert_equals([0, 0, 1], find_path_in_tree(tree, "/projects/zuice/"))
Exemplo n.º 3
0
def test_find_path_in_tree_returns_singleton_of_zero_for_root_path():
    tree = {
        "url": "/",
        "children": [
            {
                "url": "/projects/",
                "children": [
                    {"url": "/projects/funk/"},
                    {"url": "/projects/zuice/"}
                ]
            },
            {"url": "/blog/"}
        ]
    }
    assert_equals([0], find_path_in_tree(tree, "/"))
Exemplo n.º 4
0
def test_find_path_in_tree_returns_none_if_path_not_in_tree():
    tree = {
        "url": "/",
        "children": [
            {
                "url": "/projects/",
                "children": [
                    {"url": "/projects/funk/"},
                    {"url": "/projects/zuice/"}
                ]
            },
            {"url": "/blog/"}
        ]
    }
    assert_equals(None, find_path_in_tree(tree, "/contact/"))