def test_add_one_level_blob_path_to_root(): root = GitNode.root() root.add_blob('foobar') assert len(root.children) == 1 assert root.children[0].name == 'foobar' assert root.children[0].parent == root assert not root.children[0].is_tree
def test_multilevel_path_string(): root = GitNode.root('/') root.add_blob('foo/bar/ber') assert (root.path) == '/' assert (root.children[0].path) == '/foo' assert (root.children[0].children[0].path) == '/foo/bar' assert (root.children[0].children[0].children[0].path) == '/foo/bar/ber'
def test_add_one_level_path_that_already_exists_in_tree(): root = GitNode.root() root.add_blob('hearts') root.add_blob('diamonds') root.add_blob('clubs') root.add_blob('spades') root.add_blob('clubs') assert len(root.children) == 4
def test_add_multilevel_path_to_tree_that_already_has_some_parts_but_types_mismatch( ): root = GitNode.root() root.add_blob('foo/bar') with pytest.raises(Exception) as e: root.add_blob('foo/bar/ber') assert str(e.value) == 'Path "foo/bar" is not a tree.'
def test_shallow_search_without_matches(): root = GitNode.root() root.add_blob('foo.txt') root.add_blob('foo.txts') root.add_blob('foo.pdf') root.add_blob('foobar.txt') root.add_blob('foofoo.txt') root.add_blob('bar.pdf') assert root.shallow_search('*.pdfs') == []
def test_shallow_search_with_matches(): root = GitNode.root() root.add_blob('foo.txt') root.add_blob('foo.txts') root.add_blob('foo.pdf') root.add_blob('foobar.txt') root.add_blob('foofoo.txt') root.add_blob('bar.pdf') results = root.shallow_search('*.txt') assert [r.path for r in results] == ['foo.txt', 'foobar.txt', 'foofoo.txt']
def test_add_one_level_path_to_root_with_children(): root = GitNode.root() root.add_blob('hearts') root.add_blob('diamonds') root.add_blob('clubs') root.add_blob('spades') root.add_blob('foobar') assert len(root.children) == 5 assert root.children[4].name == 'foobar' assert root.children[4].parent == root assert not root.children[4].is_tree
def test_add_multilevel_path_to_tree(): root = GitNode.root() root.add_blob('foo/bar/ber') assert len(root.children) == 1 assert root.children[0].name == 'foo' assert root.children[0].is_tree assert len(root.children[0].children) == 1 assert root.children[0].children[0].name == 'bar' assert root.children[0].children[0].is_tree assert len(root.children[0].children[0].children) == 1 assert root.children[0].children[0].children[0].name == 'ber' assert not root.children[0].children[0].children[0].is_tree
def foobar_tree(): root = GitNode.root() root.add_blob('foo/bar/readme.txt') root.add_blob('foo/bar/readme.md') root.add_blob('foo/bla/blerg/wtf') root.add_blob('foo/bla/readme.txt') root.add_blob('flu/beer/readme.txt') root.add_blob('flu/beer/readme.md') root.add_blob('flu/beer/LICENSE') root.add_tree('flu/beer/beer') root.add_blob('flu/beer/beer/script.sh') root.add_blob('flu/beer/document.pdf') root.add_tree('foo/beer/beer') root.add_tree('foo/beer/blur') root.add_blob('blur') return root
def tree(): root = GitNode.root() root.add_blob('requirements.txt') root.add_blob('requirements-test.txt') root.add_blob('foo/Pipfile') root.add_blob('foo/bar/requirements-dev.txt') root.add_blob('foo/bar/requirements-docs.txt') root.add_blob('foo/bar/foobar.py') root.add_blob('foo/bar/Pipfile') root.add_blob('foo/bar/beer/Pipfile') root.add_blob('Foo.gemspec') root.add_blob('Bar.gemspec') root.add_blob('README.md') root.add_blob('Gemfile') root.add_blob('Gemfile.lock') root.add_blob('LICENSE') return root
def test_mismatch_multiple_unix_shell_style_wildcard_patterns(): root = GitNode.root('/init.d') assert not root.match_any(['foo', 'bar', 'foo*.d'])
def test_match_multiple_unix_shell_style_wildcard_patterns(): root = GitNode.root('/init.d') assert root.match_any(['foobar', '/i*.d', '/init.*'])
def test_mismatch_single_unix_shell_style_wildcard_pattern(): root = GitNode.root('/init.d') assert not root.match('*.bla')
def test_match_single_unix_shell_style_wildcard_pattern(): root = GitNode.root('/init.d') assert root.match('/[Ii]*.d')