def test_with_negated_entry(self): entry = v2.format_entry('../vdir', '~/dd:path/to/!f', self.fs) self.assertEqual( entry, { "location": f"{self.fs.home}/dd", "base": 'path/to', "selection": ['!f'] })
def test_with_complex_entry_and_absolute_path(self): config = { "location": '/var', "base": 'log', "selection": ['nginx', 'apache'] } entry = v2.format_entry('vdir', config, self.fs) self.assertEqual(entry, config)
def test_with_complex_entry_and_leading_base(self): config = { "location": '../path', "base": 'log', "selection": ['nginx', 'apache'] } entry = v2.format_entry('to/vdir', config, self.fs) self.assertEqual( entry, { "location": '/a/b/c/to/path', "base": 'log', "selection": ['nginx', 'apache'] })
def test_with_complex_entry_and_rewinding_path(self): config = { "location": '../../and/up/again', "base": 'log', "selection": ['nginx', 'apache'] } entry = v2.format_entry('vdir', config, self.fs) self.assertEqual( entry, { "location": '/a/b/and/up/again', "base": 'log', "selection": ['nginx', 'apache'] })
def test_with_complex_entry_and_relative_path(self): config = { "location": 'd', "base": 'log', "selection": ['nginx', 'apache'] } entry = v2.format_entry('vdir', config, self.fs) self.assertEqual( entry, { "location": '/a/b/c/vdir/d', "base": 'log', "selection": ['nginx', 'apache'] })
def test_with_complex_entry_and_user_path(self): config = { "location": '~/my/root', "base": 'log', "selection": ['nginx', 'apache'] } entry = v2.format_entry('vdir', config, self.fs) self.assertEqual( entry, { "location": f"{self.fs.home}/my/root", "base": 'log', "selection": ['nginx', 'apache'] })
def test_with_rewinding_base(self): entry = v2.format_entry('../vdir', '../path:target', self.fs) self.assertEqual(entry, simple_entry('/a/b/path', 'target'))
def test_with_rewinding_path(self): entry = v2.format_entry('vdir', '../../and/up/again:other', self.fs) self.assertEqual(entry, simple_entry('/a/b/and/up/again', 'other'))
def test_with_relative_path(self): entry = v2.format_entry('vdir', 'd:other', self.fs) self.assertEqual(entry, simple_entry('/a/b/c/vdir/d', 'other'))
def test_with_user_home(self): entry = v2.format_entry('vdir', '~/my/root:one/dir', self.fs) self.assertEqual(entry, simple_entry(f"{self.fs.home}/my/root", 'one/dir'))
def test_with_absolute_path(self): entry = v2.format_entry('vdir', '/root/some/path:one/dir', self.fs) self.assertEqual(entry, simple_entry('/root/some/path', 'one/dir'))