tests for joinpath

This commit is contained in:
Mike McLean 2019-09-23 16:22:12 -04:00
parent 3354da7024
commit f0cdeaab07

View file

@ -158,6 +158,28 @@ class MiscFunctionTestCase(unittest.TestCase):
for m in mocks:
m.assert_not_called()
def test_joinpath_bad(self):
bad_joins = [
['/foo', '../bar'],
['/foo', 'a/b/../../../bar'],
['/foo', '/bar'],
['/foo//', '/bar'],
['/foo', 'bar', 'baz', '/zoo'],
]
for args in bad_joins:
with self.assertRaises(ValueError):
koji.util.joinpath(*args)
def test_joinpath_good(self):
p = koji.util.joinpath('/foo', 'bar')
self.assertEquals(p, '/foo/bar')
p = koji.util.joinpath('/foo', 'bar/../baz')
self.assertEquals(p, '/foo/baz')
p = koji.util.joinpath('/foo', 'a/b/c/../../../z')
self.assertEquals(p, '/foo/z')
class ConfigFileTestCase(unittest.TestCase):
"""Test config file reading functions"""