diff options
| author | Brandon Bodnar <bodnarbm@gmail.com> | 2016-10-31 19:56:02 -0400 |
|---|---|---|
| committer | Brandon Bodnar <bodnarbm@gmail.com> | 2016-11-26 21:36:54 -0500 |
| commit | 9fc8b3a730293b8cbee2feab04c355e753b20cdf (patch) | |
| tree | 3cd5c160b5cfcabcceb4ad8725ae44fcc3b05e93 | |
| parent | e2eb4a3158ece4e9a1122a85accf95e23f6630dc (diff) | |
| download | docker-py-9fc8b3a730293b8cbee2feab04c355e753b20cdf.tar.gz | |
Add unit tests for should_check_directory.
Signed-off-by: Brandon Bodnar <bodnarbm@gmail.com>
| -rw-r--r-- | tests/unit/utils_test.py | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 57aa226..45f5914 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -25,7 +25,9 @@ from docker.utils import ( ) from docker.utils.ports import build_port_bindings, split_port -from docker.utils.utils import create_endpoint_config, format_environment +from docker.utils.utils import ( + create_endpoint_config, format_environment, should_check_directory +) from ..helpers import make_tree @@ -1092,6 +1094,78 @@ class TarTest(unittest.TestCase): ) +class ShouldCheckDirectoryTest(unittest.TestCase): + exclude_patterns = [ + 'exclude_rather_large_directory', + 'dir/with/subdir_excluded', + 'dir/with/exceptions' + ] + + include_patterns = [ + 'dir/with/exceptions/like_this_one', + 'dir/with/exceptions/in/descendents' + ] + + def test_should_check_directory_not_excluded(self): + self.assertTrue( + should_check_directory('not_excluded', self.exclude_patterns, + self.include_patterns) + ) + + self.assertTrue( + should_check_directory('dir/with', self.exclude_patterns, + self.include_patterns) + ) + + def test_shoud_check_parent_directories_of_excluded(self): + self.assertTrue( + should_check_directory('dir', self.exclude_patterns, + self.include_patterns) + ) + self.assertTrue( + should_check_directory('dir/with', self.exclude_patterns, + self.include_patterns) + ) + + def test_should_not_check_excluded_directories_with_no_exceptions(self): + self.assertFalse( + should_check_directory('exclude_rather_large_directory', + self.exclude_patterns, self.include_patterns + ) + ) + self.assertFalse( + should_check_directory('dir/with/subdir_excluded', + self.exclude_patterns, self.include_patterns + ) + ) + + def test_should_check_excluded_directory_with_exceptions(self): + self.assertTrue( + should_check_directory('dir/with/exceptions', + self.exclude_patterns, self.include_patterns + ) + ) + self.assertTrue( + should_check_directory('dir/with/exceptions/in', + self.exclude_patterns, self.include_patterns + ) + ) + + def test_should_not_check_siblings_of_exceptions(self): + self.assertFalse( + should_check_directory('dir/with/exceptions/but_not_here', + self.exclude_patterns, self.include_patterns + ) + ) + + def test_should_check_subdirectories_of_exceptions(self): + self.assertTrue( + should_check_directory('dir/with/exceptions/like_this_one/subdir', + self.exclude_patterns, self.include_patterns + ) + ) + + class FormatEnvironmentTest(unittest.TestCase): def test_format_env_binary_unicode_value(self): env_dict = { |
