desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Tests a single component to be sanitized.'
| def test_sanitize_components_one_element(self):
| mock_component_list = ['foo=bar', 'api_key=abcdefghijklmnop']
mock_ret = 'foo=bar&api_key=XXXXXXXXXX&'
ret = http._sanitize_url_components(mock_component_list, 'api_key')
self.assertEqual(ret, mock_ret)
|
'Tests two componenets to be sanitized.'
| def test_sanitize_components_multiple_elements(self):
| mock_component_list = ['foo=bar', 'foo=baz', 'api_key=testing']
mock_ret = 'foo=XXXXXXXXXX&foo=XXXXXXXXXX&api_key=testing&'
ret = http._sanitize_url_components(mock_component_list, 'foo')
self.assertEqual(ret, mock_ret)
|
'Test parsing an ordinary path'
| def test_parse_path(self):
| path = 'interesting?/path&.conf:and other things'
self.assertEqual(salt.utils.url.parse(path), (path, None))
|
'Test parsing a \'salt://\' URL'
| def test_parse_salt_url(self):
| path = '?funny/path with {interesting|chars}'
url = ('salt://' + path)
self.assertEqual(salt.utils.url.parse(url), (path, None))
|
'Test parsing a \'salt://\' URL with a \'?saltenv=\' query'
| def test_parse_salt_saltenv(self):
| saltenv = 'ambience'
path = '?funny/path&with {interesting|chars}'
url = ((('salt://' + path) + '?saltenv=') + saltenv)
self.assertEqual(salt.utils.url.parse(url), (path, saltenv))
|
'Test creating a \'salt://\' URL'
| def test_create_url(self):
| path = '? interesting/&path.filetype'
url = ('salt://' + path)
self.assertEqual(salt.utils.url.create(path), url)
|
'Test creating a \'salt://\' URL with a saltenv'
| def test_create_url_saltenv(self):
| saltenv = 'raumklang'
path = '? interesting/&path.filetype'
url = ((('salt://' + path) + '?saltenv=') + saltenv)
self.assertEqual(salt.utils.url.create(path, saltenv), url)
|
'Test not testing a \'salt://\' URL on windows'
| def test_is_escaped_windows(self):
| url = 'salt://dir/file.ini'
with patch('salt.utils.platform.is_windows', MagicMock(return_value=True)):
self.assertFalse(salt.utils.url.is_escaped(url))
|
'Test testing an escaped path'
| def test_is_escaped_escaped_path(self):
| path = '|dir/file.conf?saltenv=basic'
self.assertTrue(salt.utils.url.is_escaped(path))
|
'Test testing an unescaped path'
| def test_is_escaped_unescaped_path(self):
| path = 'dir/file.conf'
self.assertFalse(salt.utils.url.is_escaped(path))
|
'Test testing an escaped \'salt://\' URL'
| def test_is_escaped_escaped_url(self):
| url = 'salt://|dir/file.conf?saltenv=basic'
self.assertTrue(salt.utils.url.is_escaped(url))
|
'Test testing an unescaped \'salt://\' URL'
| def test_is_escaped_unescaped_url(self):
| url = 'salt://dir/file.conf'
self.assertFalse(salt.utils.url.is_escaped(url))
|
'Test testing an unescaped \'salt://\' URL'
| def test_is_escaped_generic_url(self):
| url = 'https://gentoo.org/'
self.assertFalse(salt.utils.url.is_escaped(url))
|
'Test not escaping a \'salt://\' URL on windows'
| def test_escape_windows(self):
| url = 'salt://dir/file.ini'
with patch('salt.utils.platform.is_windows', MagicMock(return_value=True)):
self.assertEqual(salt.utils.url.escape(url), url)
|
'Test escaping an escaped path'
| def test_escape_escaped_path(self):
| resource = '|dir/file.conf?saltenv=basic'
self.assertEqual(salt.utils.url.escape(resource), resource)
|
'Test escaping an unescaped path'
| def test_escape_unescaped_path(self):
| path = 'dir/file.conf'
escaped_path = ('|' + path)
self.assertEqual(salt.utils.url.escape(path), escaped_path)
|
'Test testing an escaped \'salt://\' URL'
| def test_escape_escaped_url(self):
| url = 'salt://|dir/file.conf?saltenv=basic'
self.assertEqual(salt.utils.url.escape(url), url)
|
'Test testing an unescaped \'salt://\' URL'
| def test_escape_unescaped_url(self):
| path = 'dir/file.conf'
url = ('salt://' + path)
escaped_url = ('salt://|' + path)
self.assertEqual(salt.utils.url.escape(url), escaped_url)
|
'Test testing an unescaped \'salt://\' URL'
| def test_escape_generic_url(self):
| url = 'https://gentoo.org/'
self.assertEqual(salt.utils.url.escape(url), url)
|
'Test not escaping a \'salt://\' URL on windows'
| def test_unescape_windows(self):
| url = 'salt://dir/file.ini'
with patch('salt.utils.platform.is_windows', MagicMock(return_value=True)):
self.assertEqual(salt.utils.url.unescape(url), url)
|
'Test escaping an escaped path'
| def test_unescape_escaped_path(self):
| resource = 'dir/file.conf?saltenv=basic'
escaped_path = ('|' + resource)
self.assertEqual(salt.utils.url.unescape(escaped_path), resource)
|
'Test escaping an unescaped path'
| def test_unescape_unescaped_path(self):
| path = 'dir/file.conf'
self.assertEqual(salt.utils.url.unescape(path), path)
|
'Test testing an escaped \'salt://\' URL'
| def test_unescape_escaped_url(self):
| resource = 'dir/file.conf?saltenv=basic'
url = ('salt://' + resource)
escaped_url = ('salt://|' + resource)
self.assertEqual(salt.utils.url.unescape(escaped_url), url)
|
'Test testing an unescaped \'salt://\' URL'
| def test_unescape_unescaped_url(self):
| url = 'salt://dir/file.conf'
self.assertEqual(salt.utils.url.unescape(url), url)
|
'Test testing an unescaped \'salt://\' URL'
| def test_unescape_generic_url(self):
| url = 'https://gentoo.org/'
self.assertEqual(salt.utils.url.unescape(url), url)
|
'Test not adding a saltenv to a non \'salt://\' URL'
| def test_add_env_not_salt(self):
| saltenv = 'higgs'
url = 'https://pdg.lbl.gov/'
self.assertEqual(salt.utils.url.add_env(url, saltenv), url)
|
'Test adding a saltenv to a \'salt://\' URL'
| def test_add_env(self):
| saltenv = 'erstwhile'
url = 'salt://salted/file.conf'
url_env = ((url + '?saltenv=') + saltenv)
self.assertEqual(salt.utils.url.add_env(url, saltenv), url_env)
|
'Test not splitting a saltenv from a non \'salt://\' URL'
| def test_split_env_non_salt(self):
| saltenv = 'gravitodynamics'
url = ('https://arxiv.org/find/all/?' + saltenv)
self.assertEqual(salt.utils.url.split_env(url), (url, None))
|
'Test splitting a \'salt://\' URL'
| def test_split_env(self):
| saltenv = 'elsewhere'
url = 'salt://salted/file.conf'
url_env = ((url + '?saltenv=') + saltenv)
self.assertEqual(salt.utils.url.split_env(url_env), (url, saltenv))
|
'Test URL valid validation'
| def test_validate_valid(self):
| url = 'salt://config/file.name?saltenv=vapid'
protos = ['salt', 'pepper', 'cinnamon', 'melange']
self.assertTrue(salt.utils.url.validate(url, protos))
|
'Test URL invalid validation'
| def test_validate_invalid(self):
| url = 'cumin://config/file.name?saltenv=vapid'
protos = ['salt', 'pepper', 'cinnamon', 'melange']
self.assertFalse(salt.utils.url.validate(url, protos))
|
'Test stripping of URL scheme'
| def test_strip_url_with_scheme(self):
| scheme = 'git+salt+rsync+AYB://'
resource = 'all/the/things.stuff;parameter?query=I guess'
url = (scheme + resource)
self.assertEqual(salt.utils.url.strip_proto(url), resource)
|
'Test stripping of a URL without a scheme'
| def test_strip_url_without_scheme(self):
| resource = 'all/the/things.stuff;parameter?query=I guess'
self.assertEqual(salt.utils.url.strip_proto(resource), resource)
|
'Tests that adding basic auth to a URL works as expected'
| def test_http_basic_auth(self):
| test_inputs = (((None, None), 'http://example.com'), (('user', None), 'http://[email protected]'), (('user', 'pass'), 'http://user:[email protected]'))
for ((user, password), expected) in test_inputs:
kwargs = {'url': 'http://example.com', 'user': user, 'password': password}
result = salt.utils.url.add_http_basic_auth(**kwargs)
self.assertEqual(result, expected)
kwargs['url'] = kwargs['url'].replace('http://', 'https://', 1)
expected = expected.replace('http://', 'https://', 1)
result = salt.utils.url.add_http_basic_auth(**kwargs)
self.assertEqual(result, expected)
|
'Tests that passing a non-https URL with https_only=True will raise a
ValueError.'
| def test_http_basic_auth_https_only(self):
| kwargs = {'url': 'http://example.com', 'user': 'foo', 'password': 'bar', 'https_only': True}
self.assertRaises(ValueError, salt.utils.url.add_http_basic_auth, **kwargs)
|
'Test to make sure we interact with etcd correctly'
| def test_read(self):
| with patch('etcd.Client', autospec=True) as mock:
etcd_client = mock.return_value
etcd_return = MagicMock(value='salt')
etcd_client.read.return_value = etcd_return
client = etcd_util.EtcdClient({})
self.assertEqual(client.read('/salt'), etcd_return)
etcd_client.read.assert_called_with('/salt', recursive=False, wait=False, timeout=None)
client.read('salt', True, True, 10, 5)
etcd_client.read.assert_called_with('salt', recursive=True, wait=True, timeout=10, waitIndex=5)
etcd_client.read.side_effect = etcd.EtcdKeyNotFound
self.assertRaises(etcd.EtcdKeyNotFound, client.read, 'salt')
etcd_client.read.side_effect = etcd.EtcdConnectionFailed
self.assertRaises(etcd.EtcdConnectionFailed, client.read, 'salt')
etcd_client.read.side_effect = etcd.EtcdValueError
self.assertRaises(etcd.EtcdValueError, client.read, 'salt')
etcd_client.read.side_effect = ValueError
self.assertRaises(ValueError, client.read, 'salt')
etcd_client.read.side_effect = ReadTimeoutError(None, None, None)
self.assertRaises(etcd.EtcdConnectionFailed, client.read, 'salt')
etcd_client.read.side_effect = MaxRetryError(None, None)
self.assertRaises(etcd.EtcdConnectionFailed, client.read, 'salt')
|
'Test if it get a value from etcd, by direct path'
| def test_get(self):
| with patch('etcd.Client') as mock:
client = etcd_util.EtcdClient({})
with patch.object(client, 'read', autospec=True) as mock:
mock.return_value = MagicMock(value='stack')
self.assertEqual(client.get('salt'), 'stack')
mock.assert_called_with('salt', recursive=False)
self.assertEqual(client.get('salt', recurse=True), 'stack')
mock.assert_called_with('salt', recursive=True)
mock.side_effect = iter([etcd.EtcdKeyNotFound()])
self.assertEqual(client.get('not-found'), None)
mock.side_effect = iter([etcd.EtcdConnectionFailed()])
self.assertEqual(client.get('watching'), None)
mock.side_effect = ValueError
self.assertEqual(client.get('not-found'), None)
mock.side_effect = Exception
self.assertRaises(Exception, client.get, 'some-error')
|
'Test recursive gets'
| def test_tree(self):
| with patch('etcd.Client') as mock:
client = etcd_util.EtcdClient({})
with patch.object(client, 'read', autospec=True) as mock:
(c1, c2) = (MagicMock(), MagicMock())
c1.__iter__.return_value = [MagicMock(key='/x/a', value='1'), MagicMock(key='/x/b', value='2'), MagicMock(key='/x/c', dir=True)]
c2.__iter__.return_value = [MagicMock(key='/x/c/d', value='3')]
mock.side_effect = iter([MagicMock(children=c1), MagicMock(children=c2)])
self.assertDictEqual(client.tree('/x'), {'a': '1', 'b': '2', 'c': {'d': '3'}})
mock.assert_any_call('/x')
mock.assert_any_call('/x/c')
mock.side_effect = iter([etcd.EtcdKeyNotFound()])
self.assertEqual(client.tree('not-found'), None)
mock.side_effect = ValueError
self.assertEqual(client.tree('/x'), None)
mock.side_effect = Exception
self.assertRaises(Exception, client.tree, 'some-error')
|
'Confirm that the terminal size is being set'
| @skipIf(True, 'Disabled until we can figure out why this fails when whole test suite runs.')
def test_vt_size(self):
| if (not sys.stdin.isatty()):
self.skipTest('Not attached to a TTY. The test would fail.')
cols = random.choice(range(80, 250))
terminal = salt.utils.vt.Terminal('echo "Foo!"', shell=True, cols=cols, rows=24, stream_stdout=False, stream_stderr=False)
self.assertEqual(terminal.getwinsize(), (24, cols))
terminal.wait()
terminal.close()
|
'Make a version
:return:'
| def _mk_version(self, name):
| return (name, SaltStackVersion.from_name(name))
|
'Setup a test
:return:'
| def setUp(self):
| self.globs = {'__virtualname__': 'test', '__opts__': {}, '__pillar__': {}, 'old_function': self.old_function, 'new_function': self.new_function, '_new_function': self._new_function}
self.addCleanup(delattr, self, 'globs')
self.messages = list()
self.addCleanup(delattr, self, 'messages')
patcher = patch.object(decorators, 'log', DummyLogger(self.messages))
patcher.start()
self.addCleanup(patcher.stop)
|
'Use of is_deprecated will result to the exception,
if the expiration version is lower than the current version.
A successor function is not pointed out.
:return:'
| def test_is_deprecated_version_eol(self):
| depr = decorators.is_deprecated(self.globs, 'Helium')
depr._curr_version = self._mk_version('Beryllium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.old_function)()
self.assertEqual(self.messages, ['The lifetime of the function "old_function" expired.'])
|
'Use of is_deprecated will result to the exception,
if the expiration version is lower than the current version.
A successor function is pointed out.
:return:'
| def test_is_deprecated_with_successor_eol(self):
| depr = decorators.is_deprecated(self.globs, 'Helium', with_successor='new_function')
depr._curr_version = self._mk_version('Beryllium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.old_function)()
self.assertEqual(self.messages, ['The lifetime of the function "old_function" expired. Please use its successor "new_function" instead.'])
|
'Use of is_deprecated will result to the log message,
if the expiration version is higher than the current version.
A successor function is not pointed out.
:return:'
| def test_is_deprecated(self):
| depr = decorators.is_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.old_function)(), self.old_function())
self.assertEqual(self.messages, ['The function "old_function" is deprecated and will expire in version "Beryllium".'])
|
'Use of is_deprecated will result to the log message,
if the expiration version is higher than the current version.
A successor function is pointed out.
:return:'
| def test_is_deprecated_with_successor(self):
| depr = decorators.is_deprecated(self.globs, 'Beryllium', with_successor='old_function')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.old_function)(), self.old_function())
self.assertEqual(self.messages, ['The function "old_function" is deprecated and will expire in version "Beryllium". Use successor "old_function" instead.'])
|
'Test with_deprecated should raise an exception, if a same name
function with the "_" prefix not implemented.
:return:'
| def test_with_deprecated_notfound(self):
| del self.globs['_new_function']
self.globs['__opts__']['use_deprecated'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.new_function)()
self.assertEqual(self.messages, ['The function "test.new_function" is using its deprecated version and will expire in version "Beryllium".'])
|
'Test with_deprecated should raise an exception, if a same name
function with the "_" prefix not implemented.
:return:'
| def test_with_deprecated_notfound_in_pillar(self):
| del self.globs['_new_function']
self.globs['__pillar__']['use_deprecated'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.new_function)()
self.assertEqual(self.messages, ['The function "test.new_function" is using its deprecated version and will expire in version "Beryllium".'])
|
'Test with_deprecated should not raise an exception, if a same name
function with the "_" prefix is implemented, but should use
an old version instead, if "use_deprecated" is requested.
:return:'
| def test_with_deprecated_found(self):
| self.globs['__opts__']['use_deprecated'] = ['test.new_function']
self.globs['_new_function'] = self.old_function
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.new_function)(), self.old_function())
log_msg = ['The function "test.new_function" is using its deprecated version and will expire in version "Beryllium".']
self.assertEqual(self.messages, log_msg)
|
'Test with_deprecated should not raise an exception, if a same name
function with the "_" prefix is implemented, but should use
an old version instead, if "use_deprecated" is requested.
:return:'
| def test_with_deprecated_found_in_pillar(self):
| self.globs['__pillar__']['use_deprecated'] = ['test.new_function']
self.globs['_new_function'] = self.old_function
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.new_function)(), self.old_function())
log_msg = ['The function "test.new_function" is using its deprecated version and will expire in version "Beryllium".']
self.assertEqual(self.messages, log_msg)
|
'Test with_deprecated should raise an exception, if a same name
function with the "_" prefix is implemented, "use_deprecated" is requested
and EOL is reached.
:return:'
| def test_with_deprecated_found_eol(self):
| self.globs['__opts__']['use_deprecated'] = ['test.new_function']
self.globs['_new_function'] = self.old_function
depr = decorators.with_deprecated(self.globs, 'Helium')
depr._curr_version = self._mk_version('Beryllium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.new_function)()
self.assertEqual(self.messages, ['Although function "new_function" is called, an alias "new_function" is configured as its deprecated version. The lifetime of the function "new_function" expired. Please use its successor "new_function" instead.'])
|
'Test with_deprecated should raise an exception, if a same name
function with the "_" prefix is implemented, "use_deprecated" is requested
and EOL is reached.
:return:'
| def test_with_deprecated_found_eol_in_pillar(self):
| self.globs['__pillar__']['use_deprecated'] = ['test.new_function']
self.globs['_new_function'] = self.old_function
depr = decorators.with_deprecated(self.globs, 'Helium')
depr._curr_version = self._mk_version('Beryllium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.new_function)()
self.assertEqual(self.messages, ['Although function "new_function" is called, an alias "new_function" is configured as its deprecated version. The lifetime of the function "new_function" expired. Please use its successor "new_function" instead.'])
|
'Test with_deprecated should not raise an exception, if a same name
function with the "_" prefix is implemented, but should use
a new version instead, if "use_deprecated" is not requested.
:return:'
| def test_with_deprecated_no_conf(self):
| self.globs['_new_function'] = self.old_function
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.new_function)(), self.new_function())
self.assertFalse(self.messages)
|
'Test with_deprecated should not raise an exception, if a different name
function is implemented and specified with the "with_name" parameter,
but should use an old version instead and log a warning log message.
:return:'
| def test_with_deprecated_with_name(self):
| self.globs['__opts__']['use_deprecated'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium', with_name='old_function')
depr._curr_version = self._mk_version('Helium')[1]
self.assertEqual(depr(self.new_function)(), self.old_function())
self.assertEqual(self.messages, ['The function "old_function" is deprecated and will expire in version "Beryllium". Use its successor "new_function" instead.'])
|
'Test with_deprecated should raise an exception, if a different name
function is implemented and specified with the "with_name" parameter
and EOL is reached.
:return:'
| def test_with_deprecated_with_name_eol(self):
| self.globs['__opts__']['use_deprecated'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Helium', with_name='old_function')
depr._curr_version = self._mk_version('Beryllium')[1]
with self.assertRaises(CommandExecutionError):
depr(self.new_function)()
self.assertEqual(self.messages, ['Although function "new_function" is called, an alias "old_function" is configured as its deprecated version. The lifetime of the function "old_function" expired. Please use its successor "new_function" instead.'])
|
'Test with_deprecated using opt-in policy,
where newer function is not used, unless configured.
:return:'
| def test_with_deprecated_opt_in_default(self):
| depr = decorators.with_deprecated(self.globs, 'Beryllium', policy=decorators._DeprecationDecorator.OPT_IN)
depr._curr_version = self._mk_version('Helium')[1]
assert (depr(self.new_function)() == self.old_function())
assert (self.messages == ['The function "test.new_function" is using its deprecated version and will expire in version "Beryllium".'])
|
'Test with_deprecated using opt-in policy,
where newer function is used as per configuration.
:return:'
| def test_with_deprecated_opt_in_use_superseded(self):
| self.globs['__opts__']['use_superseded'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium', policy=decorators._DeprecationDecorator.OPT_IN)
depr._curr_version = self._mk_version('Helium')[1]
assert (depr(self.new_function)() == self.new_function())
assert (not self.messages)
|
'Test with_deprecated using opt-in policy,
where newer function is used as per configuration.
:return:'
| def test_with_deprecated_opt_in_use_superseded_in_pillar(self):
| self.globs['__pillar__']['use_superseded'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium', policy=decorators._DeprecationDecorator.OPT_IN)
depr._curr_version = self._mk_version('Helium')[1]
assert (depr(self.new_function)() == self.new_function())
assert (not self.messages)
|
'Test with_deprecated misconfiguration.
:return:'
| def test_with_deprecated_opt_in_use_superseded_and_deprecated(self):
| self.globs['__opts__']['use_deprecated'] = ['test.new_function']
self.globs['__opts__']['use_superseded'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
with self.assertRaises(SaltConfigurationError):
assert (depr(self.new_function)() == self.new_function())
|
'Test with_deprecated misconfiguration.
:return:'
| def test_with_deprecated_opt_in_use_superseded_and_deprecated_in_pillar(self):
| self.globs['__pillar__']['use_deprecated'] = ['test.new_function']
self.globs['__pillar__']['use_superseded'] = ['test.new_function']
depr = decorators.with_deprecated(self.globs, 'Beryllium')
depr._curr_version = self._mk_version('Helium')[1]
with self.assertRaises(SaltConfigurationError):
assert (depr(self.new_function)() == self.new_function())
|
'Test skip_translate kwarg'
| def tearDown(self):
| name = self.id().split('.')[(-1)][5:]
expected = ({name: 'foo'}, {}, [])
self.assertEqual(docker_utils.translate_input(**{name: 'foo', 'skip_translate': True}), expected)
self.assertEqual(docker_utils.translate_input(**{name: 'foo', 'skip_translate': [name]}), expected)
|
'Should be a bool or converted to one'
| @assert_bool
def test_auto_remove(self):
| pass
|
'Test the "binds" kwarg. Any volumes not defined in the "volumes" kwarg
should be added to the results.'
| def test_binds(self):
| self.assertEqual(docker_utils.translate_input(binds='/srv/www:/var/www:ro', volumes='/testing'), ({'binds': ['/srv/www:/var/www:ro'], 'volumes': ['/testing', '/var/www']}, {}, []))
self.assertEqual(docker_utils.translate_input(binds=['/srv/www:/var/www:ro'], volumes='/testing'), ({'binds': ['/srv/www:/var/www:ro'], 'volumes': ['/testing', '/var/www']}, {}, []))
self.assertEqual(docker_utils.translate_input(binds={'/srv/www': {'bind': '/var/www', 'mode': 'ro'}}, volumes='/testing'), ({'binds': {'/srv/www': {'bind': '/var/www', 'mode': 'ro'}}, 'volumes': ['/testing', '/var/www']}, {}, []))
|
'Should be an int or converted to one'
| @assert_int
def test_blkio_weight(self):
| pass
|
'Should translate a list of PATH:WEIGHT pairs to a list of dictionaries
with the following format: {\'Path\': PATH, \'Weight\': WEIGHT}'
| def test_blkio_weight_device(self):
| expected = ({'blkio_weight_device': [{'Path': '/dev/sda', 'Weight': 100}, {'Path': '/dev/sdb', 'Weight': 200}]}, {}, [])
self.assertEqual(docker_utils.translate_input(blkio_weight_device='/dev/sda:100,/dev/sdb:200'), expected)
self.assertEqual(docker_utils.translate_input(blkio_weight_device=['/dev/sda:100', '/dev/sdb:200']), expected)
self.assertEqual(docker_utils.translate_input(blkio_weight_device='foo'), ({}, {'blkio_weight_device': "'foo' contains 1 value(s) (expected 2)"}, []))
self.assertEqual(docker_utils.translate_input(blkio_weight_device='foo:bar:baz'), ({}, {'blkio_weight_device': "'foo:bar:baz' contains 3 value(s) (expected 2)"}, []))
self.assertEqual(docker_utils.translate_input(blkio_weight_device=['/dev/sda:100', '/dev/sdb:foo']), ({}, {'blkio_weight_device': "Weight 'foo' for path '/dev/sdb' is not an integer"}, []))
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_cap_add(self):
| pass
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_cap_drop(self):
| pass
|
'Can either be a string or a comma-separated or Python list of strings.'
| @assert_cmd
def test_command(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_cpuset_cpus(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_cpuset_mems(self):
| pass
|
'Should be an int or converted to one'
| @assert_int
def test_cpu_group(self):
| pass
|
'Should be an int or converted to one'
| @assert_int
def test_cpu_period(self):
| pass
|
'Should be an int or converted to one'
| @assert_int
def test_cpu_shares(self):
| pass
|
'Should be a bool or converted to one'
| @assert_bool
def test_detach(self):
| pass
|
'CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{\'Path\': path, \'Rate\': rate}]'
| @assert_device_rates
def test_device_read_bps(self):
| pass
|
'CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{\'Path\': path, \'Rate\': rate}]'
| @assert_device_rates
def test_device_read_iops(self):
| pass
|
'CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{\'Path\': path, \'Rate\': rate}]'
| @assert_device_rates
def test_device_write_bps(self):
| pass
|
'CLI input is a list of PATH:RATE pairs, but the API expects a list of
dictionaries in the format [{\'Path\': path, \'Rate\': rate}]'
| @assert_device_rates
def test_device_write_iops(self):
| pass
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_devices(self):
| pass
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_dns_opt(self):
| pass
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_dns_search(self):
| pass
|
'While this is a stringlist, it also supports IP address validation, so
it can\'t use the test_stringlist decorator because we need to test both
with and without validation, and it isn\'t necessary to make all other
stringlist tests also do that same kind of testing.'
| def test_dns(self):
| expected = ({'dns': ['8.8.8.8', '8.8.4.4']}, {}, [])
self.assertEqual(docker_utils.translate_input(dns='8.8.8.8,8.8.4.4', validate_ip_addrs=True), expected)
self.assertEqual(docker_utils.translate_input(dns=['8.8.8.8', '8.8.4.4'], validate_ip_addrs=True), expected)
expected = ({}, {'dns': "'8.8.8.888' is not a valid IP address"}, [])
self.assertEqual(docker_utils.translate_input(dns='8.8.8.888,8.8.4.4', validate_ip_addrs=True), expected)
self.assertEqual(docker_utils.translate_input(dns=['8.8.8.888', '8.8.4.4'], validate_ip_addrs=True), expected)
expected = ({'dns': ['foo', 'bar']}, {}, [])
self.assertEqual(docker_utils.translate_input(dns='foo,bar', validate_ip_addrs=False), expected)
self.assertEqual(docker_utils.translate_input(dns=['foo', 'bar'], validate_ip_addrs=False), expected)
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_domainname(self):
| pass
|
'Can either be a string or a comma-separated or Python list of strings.'
| @assert_cmd
def test_entrypoint(self):
| pass
|
'Can be passed in several formats but must end up as a dictionary
mapping keys to values'
| @assert_key_equals_value
def test_environment(self):
| pass
|
'Can be passed as a list of key:value pairs but can\'t be simply tested
using @assert_key_colon_value since we need to test both with and without
IP address validation.'
| def test_extra_hosts(self):
| expected = ({'extra_hosts': {'web1': '10.9.8.7', 'web2': '10.9.8.8'}}, {}, [])
self.assertEqual(docker_utils.translate_input(extra_hosts='web1:10.9.8.7,web2:10.9.8.8', validate_ip_addrs=True), expected)
self.assertEqual(docker_utils.translate_input(extra_hosts=['web1:10.9.8.7', 'web2:10.9.8.8'], validate_ip_addrs=True), expected)
expected = ({}, {'extra_hosts': "'10.9.8.299' is not a valid IP address"}, [])
self.assertEqual(docker_utils.translate_input(extra_hosts='web1:10.9.8.299,web2:10.9.8.8', validate_ip_addrs=True), expected)
self.assertEqual(docker_utils.translate_input(extra_hosts=['web1:10.9.8.299', 'web2:10.9.8.8'], validate_ip_addrs=True), expected)
expected = ({'extra_hosts': {'foo': 'bar', 'baz': 'qux'}}, {}, [])
self.assertEqual(docker_utils.translate_input(extra_hosts='foo:bar,baz:qux', validate_ip_addrs=False), expected)
self.assertEqual(docker_utils.translate_input(extra_hosts=['foo:bar', 'baz:qux'], validate_ip_addrs=False), expected)
|
'Should be a list of strings or converted to one'
| @assert_stringlist
def test_group_add(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_hostname(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_ipc_mode(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_isolation(self):
| pass
|
'Can be passed as a list of key=value pairs or a dictionary, and must
ultimately end up as a dictionary.'
| @assert_key_equals_value
def test_labels(self):
| pass
|
'Can be passed as a list of key:value pairs or a dictionary, and must
ultimately end up as a dictionary.'
| @assert_key_colon_value
def test_links(self):
| pass
|
'This is a mixture of log_driver and log_opt, which get combined into a
dictionary.
log_driver is a simple string, but log_opt can be passed in several
ways, so we need to test them all.'
| def test_log_config(self):
| expected = ({'log_config': {'Type': 'foo', 'Config': {'foo': 'bar', 'baz': 'qux'}}}, {}, [])
self.assertEqual(docker_utils.translate_input(log_driver='foo', log_opt='foo=bar,baz=qux'), expected)
self.assertEqual(docker_utils.translate_input(log_driver='foo', log_opt=['foo=bar', 'baz=qux']), expected)
self.assertEqual(docker_utils.translate_input(log_driver='foo', log_opt={'foo': 'bar', 'baz': 'qux'}), expected)
self.assertEqual(docker_utils.translate_input(log_driver='foo'), ({'log_config': {'Type': 'foo', 'Config': {}}}, {}, []))
self.assertEqual(docker_utils.translate_input(log_opt={'foo': 'bar', 'baz': 'qux'}), ({'log_config': {'Type': 'none', 'Config': {'foo': 'bar', 'baz': 'qux'}}}, {}, []))
|
'Can be passed as a list of key=value pairs or a dictionary, and must
ultimately end up as a dictionary.'
| @assert_key_equals_value
def test_lxc_conf(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_mac_address(self):
| pass
|
'Should be a string or converted to one'
| @assert_int_or_string
def test_mem_limit(self):
| pass
|
'Should be an int or converted to one'
| @assert_int
def test_mem_swappiness(self):
| pass
|
'Should be a string or converted to one'
| @assert_int_or_string
def test_memswap_limit(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_name(self):
| pass
|
'Should be a bool or converted to one'
| @assert_bool
def test_network_disabled(self):
| pass
|
'Should be a string or converted to one'
| @assert_string
def test_network_mode(self):
| pass
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.