summaryrefslogtreecommitdiffstats
path: root/tests/cmd/test_recurse_path.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cmd/test_recurse_path.py')
-rw-r--r--tests/cmd/test_recurse_path.py79
1 files changed, 41 insertions, 38 deletions
diff --git a/tests/cmd/test_recurse_path.py b/tests/cmd/test_recurse_path.py
index 2fb3eb32..acb609f3 100644
--- a/tests/cmd/test_recurse_path.py
+++ b/tests/cmd/test_recurse_path.py
@@ -22,6 +22,7 @@ def fake_os_walk(paths):
new_path = "/".join([top, name])
for x in os_walk(new_path, topdown):
yield x
+
return os_walk
@@ -29,10 +30,9 @@ def fake_os_walk(paths):
# attempting to create the cache directory multiple times as the tests
# are run in parallel. Stub out the JobCache to ensure that each
# test can safely create the object without effect.
-@mock.patch('jenkins_jobs.builder.JobCache', mock.MagicMock)
+@mock.patch("jenkins_jobs.builder.JobCache", mock.MagicMock)
class CmdRecursePath(testtools.TestCase):
-
- @mock.patch('jenkins_jobs.utils.os.walk')
+ @mock.patch("jenkins_jobs.utils.os.walk")
def test_recursive_path_option_exclude_pattern(self, oswalk_mock):
"""
Test paths returned by the recursive processing when using pattern
@@ -48,21 +48,21 @@ class CmdRecursePath(testtools.TestCase):
"""
os_walk_paths = [
- ('/jjb_configs', (['dir1', 'dir2', 'dir3', 'test3'], ())),
- ('/jjb_configs/dir1', (['test1'], ('file'))),
- ('/jjb_configs/dir2', (['test2'], ())),
- ('/jjb_configs/dir3', (['bar'], ())),
- ('/jjb_configs/dir3/bar', ([], ())),
- ('/jjb_configs/test3/bar', None),
- ('/jjb_configs/test3/baz', None)
+ ("/jjb_configs", (["dir1", "dir2", "dir3", "test3"], ())),
+ ("/jjb_configs/dir1", (["test1"], ("file"))),
+ ("/jjb_configs/dir2", (["test2"], ())),
+ ("/jjb_configs/dir3", (["bar"], ())),
+ ("/jjb_configs/dir3/bar", ([], ())),
+ ("/jjb_configs/test3/bar", None),
+ ("/jjb_configs/test3/baz", None),
]
paths = [k for k, v in os_walk_paths if v is not None]
oswalk_mock.side_effect = fake_os_walk(os_walk_paths)
- self.assertEqual(paths, utils.recurse_path('/jjb_configs', ['test*']))
+ self.assertEqual(paths, utils.recurse_path("/jjb_configs", ["test*"]))
- @mock.patch('jenkins_jobs.utils.os.walk')
+ @mock.patch("jenkins_jobs.utils.os.walk")
def test_recursive_path_option_exclude_absolute(self, oswalk_mock):
"""
Test paths returned by the recursive processing when using absolute
@@ -78,25 +78,26 @@ class CmdRecursePath(testtools.TestCase):
"""
os_walk_paths = [
- ('/jjb_configs', (['dir1', 'dir2', 'dir3', 'test3'], ())),
- ('/jjb_configs/dir1', None),
- ('/jjb_configs/dir2', (['test2'], ())),
- ('/jjb_configs/dir3', (['bar'], ())),
- ('/jjb_configs/test3', (['bar', 'baz'], ())),
- ('/jjb_configs/dir2/test2', ([], ())),
- ('/jjb_configs/dir3/bar', ([], ())),
- ('/jjb_configs/test3/bar', ([], ())),
- ('/jjb_configs/test3/baz', ([], ()))
+ ("/jjb_configs", (["dir1", "dir2", "dir3", "test3"], ())),
+ ("/jjb_configs/dir1", None),
+ ("/jjb_configs/dir2", (["test2"], ())),
+ ("/jjb_configs/dir3", (["bar"], ())),
+ ("/jjb_configs/test3", (["bar", "baz"], ())),
+ ("/jjb_configs/dir2/test2", ([], ())),
+ ("/jjb_configs/dir3/bar", ([], ())),
+ ("/jjb_configs/test3/bar", ([], ())),
+ ("/jjb_configs/test3/baz", ([], ())),
]
paths = [k for k, v in os_walk_paths if v is not None]
oswalk_mock.side_effect = fake_os_walk(os_walk_paths)
- self.assertEqual(paths, utils.recurse_path('/jjb_configs',
- ['/jjb_configs/dir1']))
+ self.assertEqual(
+ paths, utils.recurse_path("/jjb_configs", ["/jjb_configs/dir1"])
+ )
- @mock.patch('jenkins_jobs.utils.os.walk')
+ @mock.patch("jenkins_jobs.utils.os.walk")
def test_recursive_path_option_exclude_relative(self, oswalk_mock):
"""
Test paths returned by the recursive processing when using relative
@@ -112,25 +113,27 @@ class CmdRecursePath(testtools.TestCase):
"""
os_walk_paths = [
- ('jjb_configs', (['dir1', 'dir2', 'dir3', 'test3'], ())),
- ('jjb_configs/dir1', (['test'], ('file'))),
- ('jjb_configs/dir2', (['test2'], ())),
- ('jjb_configs/dir3', (['bar'], ())),
- ('jjb_configs/test3', (['bar', 'baz'], ())),
- ('jjb_configs/dir1/test', ([], ())),
- ('jjb_configs/dir2/test2', ([], ())),
- ('jjb_configs/dir3/bar', ([], ())),
- ('jjb_configs/test3/bar', None),
- ('jjb_configs/test3/baz', ([], ()))
+ ("jjb_configs", (["dir1", "dir2", "dir3", "test3"], ())),
+ ("jjb_configs/dir1", (["test"], ("file"))),
+ ("jjb_configs/dir2", (["test2"], ())),
+ ("jjb_configs/dir3", (["bar"], ())),
+ ("jjb_configs/test3", (["bar", "baz"], ())),
+ ("jjb_configs/dir1/test", ([], ())),
+ ("jjb_configs/dir2/test2", ([], ())),
+ ("jjb_configs/dir3/bar", ([], ())),
+ ("jjb_configs/test3/bar", None),
+ ("jjb_configs/test3/baz", ([], ())),
]
rel_os_walk_paths = [
- (os.path.abspath(
- os.path.join(os.path.curdir, k)), v) for k, v in os_walk_paths]
+ (os.path.abspath(os.path.join(os.path.curdir, k)), v)
+ for k, v in os_walk_paths
+ ]
paths = [k for k, v in rel_os_walk_paths if v is not None]
oswalk_mock.side_effect = fake_os_walk(rel_os_walk_paths)
- self.assertEqual(paths, utils.recurse_path('jjb_configs',
- ['jjb_configs/test3/bar']))
+ self.assertEqual(
+ paths, utils.recurse_path("jjb_configs", ["jjb_configs/test3/bar"])
+ )