Beispiel #1
0
    def test_with_existing_entry(self):
        self.fs._set_file('path/to/vdir/f1')

        structure = [simple_entry('/a/b/dir', 'f1')]
        v2.build_entries('path/to/vdir', structure, self.fs)

        self.assertEqual(list(self.fs.created_links), [])
Beispiel #2
0
    def test_for_simple_entries(self):
        config = {'location': '/a/b/dir', 'selection': ['f1', 'f2']}
        v2.build_entries('path/to/vdir', [config], self.fs)

        self.assertEqual(
            set(self.fs.created_links),
            set([('/a/b/dir/f1', 'path/to/vdir/f1'),
                 ('/a/b/dir/f2', 'path/to/vdir/f2')]))
Beispiel #3
0
    def test_for_many_not_entries_without_base(self):
        entries = ['a', 'ab', 'not-this', 'dc']
        self.fs._set_entries('/path', entries)
        for e in entries:
            self.fs._set_dir(f"/path/{e}")

        config = {'location': '/path', 'selection': ['!not-this', '!a', '!c']}
        v2.build_entries('to/vdir', [config], self.fs)

        self.assertEqual(self.fs.created_dirs, [])
        self.assertEqual(
            set(self.fs.created_links),
            set([('/path/ab', 'to/vdir/ab'), ('/path/dc', 'to/vdir/dc')]))
Beispiel #4
0
    def test_for_not_entry(self):
        entries = ['a', 'b', 'not-this', 'c']
        self.fs._set_entries('/path', entries)
        for e in entries:
            self.fs._set_dir(f"/path/{e}")

        structure = [simple_entry('/path', '!not-this')]
        v2.build_entries('to/vdir', structure, self.fs)

        self.assertEqual(
            set(self.fs.created_links),
            set([('/path/a', 'to/vdir/a'), ('/path/b', 'to/vdir/b'),
                 ('/path/c', 'to/vdir/c')]))
Beispiel #5
0
    def test_not_entry_ignore_file(self):
        dir_entries = ['a', 'not-this', 'b']
        for e in dir_entries:
            self.fs._set_dir(f"/path/{e}")
        file_entries = ['c', 'd']
        self.fs._set_entries('/path', dir_entries + file_entries)

        config = simple_entry('/path', '!not-this')
        v2.build_entries('to/vdir', [config], self.fs)

        self.assertEqual(self.fs.created_dirs, [])
        self.assertEqual(
            set(self.fs.created_links),
            set([('/path/a', 'to/vdir/a'), ('/path/b', 'to/vdir/b')]))
Beispiel #6
0
    def test_for_many_entries(self):
        entries = ['a', 'not-this', 'b']
        self.fs._set_entries('/root', entries)
        for e in entries:
            self.fs._set_dir(f"/root/{e}")

        structure = [
            simple_entry('/a/b/dir', 'f1'),
            simple_entry('/my/home/has/dir', 'f2'),
            simple_entry('/root', '!not-this')
        ]
        v2.build_entries('path/to/vdir', structure, self.fs)

        self.assertEqual(
            set(self.fs.created_links),
            set([('/a/b/dir/f1', 'path/to/vdir/f1'),
                 ('/my/home/has/dir/f2', 'path/to/vdir/f2'),
                 ('/root/a', 'path/to/vdir/a'),
                 ('/root/b', 'path/to/vdir/b')]))
Beispiel #7
0
    def test_for_not_entry_with_base(self):
        entries = ['a', 'b', 'not-this', 'c']
        self.fs._set_entries('/path/inside/dir', entries)
        for e in entries:
            self.fs._set_dir(f"/path/inside/dir/{e}")

        config = {
            'location': '/path',
            'base': 'inside/dir',
            'selection': ['!not-this']
        }
        v2.build_entries('to/vdir', [config], self.fs)

        self.assertEqual(self.fs.created_dirs,
                         ['to/vdir/inside', 'to/vdir/inside/dir'])
        self.assertEqual(
            set(self.fs.created_links),
            set([('/path/inside/dir/a', 'to/vdir/inside/dir/a'),
                 ('/path/inside/dir/b', 'to/vdir/inside/dir/b'),
                 ('/path/inside/dir/c', 'to/vdir/inside/dir/c')]))
Beispiel #8
0
    def test_for_simple_entry(self):
        structure = [simple_entry('/a/b/dir', 'f1')]
        v2.build_entries('path/to/vdir', structure, self.fs)

        self.assertEqual(set(self.fs.created_links),
                         set([('/a/b/dir/f1', 'path/to/vdir/f1')]))