summaryrefslogtreecommitdiff
path: root/tests/unit/utils_test.py
diff options
context:
space:
mode:
authorJoffrey F <f.joffrey@gmail.com>2018-02-22 14:43:15 -0800
committerGitHub <noreply@github.com>2018-02-22 14:43:15 -0800
commit79f27c68ab7835fb26151cd559ecc64d8aeb15ac (patch)
treefa7cdb10ea7a8d5cc861ea605f1999c213a12757 /tests/unit/utils_test.py
parentc9ee0222fa931365b4af19d1cbbc61be671664f1 (diff)
parent1d85818f4caeba437d4200a6b8f870beb28ca5a2 (diff)
downloaddocker-py-79f27c68ab7835fb26151cd559ecc64d8aeb15ac.tar.gz
Merge pull request #1921 from docker/3.1.0-release3.1.0
3.1.0 release
Diffstat (limited to 'tests/unit/utils_test.py')
-rw-r--r--tests/unit/utils_test.py91
1 files changed, 27 insertions, 64 deletions
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index eedcf71..8a4b193 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -23,7 +23,6 @@ from docker.utils import (
decode_json_header, tar, split_command, parse_devices, update_headers,
)
-from docker.utils.build import should_check_directory
from docker.utils.ports import build_port_bindings, split_port
from docker.utils.utils import format_environment
@@ -758,6 +757,13 @@ class ExcludePathsTest(unittest.TestCase):
self.all_paths - set(['foo/a.py'])
)
+ def test_exclude_include_absolute_path(self):
+ base = make_tree([], ['a.py', 'b.py'])
+ assert exclude_paths(
+ base,
+ ['/*', '!/*.py']
+ ) == set(['a.py', 'b.py'])
+
def test_single_subdir_with_path_traversal(self):
assert self.exclude(['foo/whoops/../a.py']) == convert_paths(
self.all_paths - set(['foo/a.py'])
@@ -876,6 +882,26 @@ class ExcludePathsTest(unittest.TestCase):
)
)
+ def test_include_wildcard(self):
+ base = make_tree(['a'], ['a/b.py'])
+ assert exclude_paths(
+ base,
+ ['*', '!*/b.py']
+ ) == convert_paths(['a/b.py'])
+
+ def test_last_line_precedence(self):
+ base = make_tree(
+ [],
+ ['garbage.md',
+ 'thrash.md',
+ 'README.md',
+ 'README-bis.md',
+ 'README-secret.md'])
+ assert exclude_paths(
+ base,
+ ['*.md', '!README*.md', 'README-secret.md']
+ ) == set(['README.md', 'README-bis.md'])
+
class TarTest(unittest.TestCase):
def test_tar_with_excludes(self):
@@ -1012,69 +1038,6 @@ class TarTest(unittest.TestCase):
assert tar_data.getmember('th.txt').mtime == -3600
-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):
- assert should_check_directory(
- 'not_excluded', self.exclude_patterns, self.include_patterns
- )
- assert should_check_directory(
- convert_path('dir/with'), self.exclude_patterns,
- self.include_patterns
- )
-
- def test_shoud_check_parent_directories_of_excluded(self):
- assert should_check_directory(
- 'dir', self.exclude_patterns, self.include_patterns
- )
- assert should_check_directory(
- convert_path('dir/with'), self.exclude_patterns,
- self.include_patterns
- )
-
- def test_should_not_check_excluded_directories_with_no_exceptions(self):
- assert not should_check_directory(
- 'exclude_rather_large_directory', self.exclude_patterns,
- self.include_patterns
- )
- assert not should_check_directory(
- convert_path('dir/with/subdir_excluded'), self.exclude_patterns,
- self.include_patterns
- )
-
- def test_should_check_excluded_directory_with_exceptions(self):
- assert should_check_directory(
- convert_path('dir/with/exceptions'), self.exclude_patterns,
- self.include_patterns
- )
- assert should_check_directory(
- convert_path('dir/with/exceptions/in'), self.exclude_patterns,
- self.include_patterns
- )
-
- def test_should_not_check_siblings_of_exceptions(self):
- assert not should_check_directory(
- convert_path('dir/with/exceptions/but_not_here'),
- self.exclude_patterns, self.include_patterns
- )
-
- def test_should_check_subdirectories_of_exceptions(self):
- assert should_check_directory(
- convert_path('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 = {