コード例 #1
0
    def test_recursive_path_option_exclude_absolute(self, oswalk_mock):
        """
        Test paths returned by the recursive processing when using absolute
        excludes.

        testing paths
            /jjb_configs/dir1/test1/
            /jjb_configs/dir1/file
            /jjb_configs/dir2/test2/
            /jjb_configs/dir3/bar/
            /jjb_configs/test3/bar/
            /jjb_configs/test3/baz/
        """

        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', ([], ()))]

        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, cmd.recurse_path('/jjb_configs', ['/jjb_configs/dir1']))
コード例 #2
0
    def test_recursive_path_option_exclude_absolute(self, oswalk_mock):
        """
        Test paths returned by the recursive processing when using absolute
        excludes.

        testing paths
            /jjb_configs/dir1/test1/
            /jjb_configs/dir1/file
            /jjb_configs/dir2/test2/
            /jjb_configs/dir3/bar/
            /jjb_configs/test3/bar/
            /jjb_configs/test3/baz/
        """

        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', ([], ()))
        ]

        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, cmd.recurse_path('/jjb_configs',
                                                 ['/jjb_configs/dir1']))
コード例 #3
0
ファイル: test_recurse_path.py プロジェクト: simzacks/jjb
    def test_recursive_path_option_exclude_relative(self, oswalk_mock):
        """
        Test paths returned by the recursive processing when using relative
        excludes.

        testing paths
            ./jjb_configs/dir1/test/
            ./jjb_configs/dir1/file
            ./jjb_configs/dir2/test/
            ./jjb_configs/dir3/bar/
            ./jjb_configs/test3/bar/
            ./jjb_configs/test3/baz/
        """

        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', ([], ()))
        ]

        rel_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, cmd.recurse_path('jjb_configs',
                                                 ['jjb_configs/test3/bar']))