示例#1
0
def test_items_should_contains_all_entries(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    items = entry.items()
    assert entry.id in items
    assert child.id in items
示例#2
0
def test_contains_with_entry(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    invalid = Entry(None, 'invalid_id', 'Test Child')
    entry.link(child)
    assert child in entry
    assert invalid not in entry
def test_wrap(test_root_entry_json, test_entry_json, test_child_entry_json):
    root_entry = RootEntry(**test_root_entry_json)
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    root_entry.wrap(entry)
    assert entry in root_entry.children
示例#4
0
def test_link(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    assert len(entry.children) == 1
    assert len(child.parents) == 1
    assert child in entry.children
    assert entry in child.parents
def test_wrap_should_not_add_additional_children(test_root_entry_json,
                                                 test_entry_json,
                                                 test_child_entry_json):
    root_entry = RootEntry(**test_root_entry_json)
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    root_entry.wrap(entry)
    assert len(root_entry.children) == 1
def test_items_should_not_contains_root_id(test_root_entry_json,
                                           test_entry_json,
                                           test_child_entry_json):
    root_entry = RootEntry(**test_root_entry_json)
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    root_entry.wrap(entry)
    root_items = root_entry.items()
    assert root_entry.id not in root_items
def test_items_should_not_contains_additional_item(test_root_entry_json,
                                                   test_entry_json,
                                                   test_child_entry_json):
    root_entry = RootEntry(**test_root_entry_json)
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    root_entry.wrap(entry)
    root_items = root_entry.items()
    assert len(root_items) == 2
def test_items_should_contains_all_entries(test_root_entry_json,
                                           test_entry_json,
                                           test_child_entry_json):
    root_entry = RootEntry(**test_root_entry_json)
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    root_entry.wrap(entry)
    items = entry.items()
    root_items = root_entry.items()
    assert all(map(lambda item: item in root_items, items))
示例#9
0
def test_getitem(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    assert entry[child.id] == child
示例#10
0
def test_dirs(test_root_dir, test_entry_json, test_child_entry_json):
    entry = Entry(root_dir=test_root_dir, **test_entry_json)
    child = Entry(root_dir=test_root_dir, **test_child_entry_json)
    entry.link(child)
    assert os.path.join(test_root_dir, entry.proper_name, child.proper_name) in child.dirs
示例#11
0
def test_paths(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    assert os.path.join(entry.proper_name, child.proper_name) in child.paths
示例#12
0
def test_contains_with_str(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    assert child.id in entry
    assert 'invalid_id' not in entry
示例#13
0
def test_link_already_linked_child(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    with pytest.raises(ValueError):
        entry.link(child)
示例#14
0
def test_link_with_intruder_child(test_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, 'invalid_id', 'Test Child')
    with pytest.raises(ValueError):
        entry.link(child)
示例#15
0
def test_link_with_invalid_type(test_entry_json):
    entry = Entry(None, **test_entry_json)
    with pytest.raises(TypeError):
        entry.link('child')
示例#16
0
def test_items_should_not_contains_additional_item(test_entry_json, test_child_entry_json):
    entry = Entry(None, **test_entry_json)
    child = Entry(None, **test_child_entry_json)
    entry.link(child)
    items = entry.items()
    assert len(items) == 2