desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Try and deny a record that already exists'
| def test_absent_record_does_not_exist(self):
| result = libcloud_dns.record_absent('mail', 'test.com', 'A', '127.0.0.1', 'test')
self.assertTrue(result)
|
'Assert that when you try and ensure present state for a record to a zone that doesn\'t exist
it fails gracefully'
| def test_present_zone_not_found(self):
| result = libcloud_dns.record_present('mail', 'notatest.com', 'A', '127.0.0.1', 'test')
self.assertFalse(result['result'])
|
'Assert that when you try and ensure absent state for a record to a zone that doesn\'t exist
it fails gracefully'
| def test_absent_zone_not_found(self):
| result = libcloud_dns.record_absent('mail', 'notatest.com', 'A', '127.0.0.1', 'test')
self.assertFalse(result['result'])
|
'Assert that a zone is present (that did not exist)'
| def test_zone_present(self):
| result = libcloud_dns.zone_present('testing.com', 'master', 'test1')
self.assertTrue(result)
|
'Assert that a zone is present (that did exist)'
| def test_zone_already_present(self):
| result = libcloud_dns.zone_present('test.com', 'master', 'test1')
self.assertTrue(result)
|
'Assert that a zone that did exist is absent'
| def test_zone_absent(self):
| result = libcloud_dns.zone_absent('test.com', 'test1')
self.assertTrue(result)
|
'Assert that a zone that did not exist is absent'
| def test_zone_already_absent(self):
| result = libcloud_dns.zone_absent('testing.com', 'test1')
self.assertTrue(result)
|
'Test to ensure a Linux ACL is present'
| def test_present(self):
| self.maxDiff = None
name = '/root'
acl_type = 'users'
acl_name = 'damian'
perms = 'rwx'
mock = MagicMock(side_effect=[{name: {acl_type: [{acl_name: {'octal': 'A'}}]}}, {name: {acl_type: [{acl_name: {'octal': 'A'}}]}}, {name: {acl_type: [{acl_name: {'octal': 'A'}}]}}, {name: {acl_type: [{}]}}, {n... |
'Test to ensure a Linux ACL does not exist'
| def test_absent(self):
| name = '/root'
acl_type = 'users'
acl_name = 'damian'
perms = 'rwx'
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
mock = MagicMock(side_effect=[{name: {acl_type: [{acl_name: {'octal': 'A'}}]}}, {name: {acl_type: ''}}])
with patch.dict(linux_acl.__salt__, {'acl.getfacl': ... |
'Test to return the current load average for the specified minion.'
| def test_loadavg(self):
| name = 'mymonitor'
ret = {'name': name, 'changes': {}, 'result': True, 'data': {}, 'comment': ''}
mock = MagicMock(return_value=[])
with patch.dict(status.__salt__, {'status.loadavg': mock}):
comt = 'Requested load average mymonitor not available '
ret.update({'comment'... |
'Test to return whether the specified signature
is found in the process tree.'
| def test_process(self):
| name = 'mymonitor'
ret = {'name': name, 'changes': {}, 'result': True, 'data': {}, 'comment': ''}
mock = MagicMock(side_effect=[{}, {name: 1}])
with patch.dict(status.__salt__, {'status.pid': mock}):
comt = 'Process signature "mymonitor" not found '
ret.update({'comment': ... |
'init method'
| def __init__(self, master_config):
| pass
|
'Mock cmd method'
| @staticmethod
def cmd(arg1, arg2):
| return []
|
'Test to refresh the winrepo.p file of the repository'
| def test_genrepo(self):
| ret = {'name': 'salt', 'changes': {}, 'result': False, 'comment': ''}
ret.update({'comment': '{0} is missing'.format(os.sep.join([BASE_FILE_ROOTS_DIR, 'win', 'repo']))})
self.assertDictEqual(winrepo.genrepo('salt'), ret)
mock = MagicMock(return_value={'winrepo_dir': 'salt', 'winrepo_cachefile': 'a... |
'Test to verifies that the specified host is known by the specified user.'
| def test_present(self):
| name = 'github.com'
user = 'root'
key = '16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48'
fingerprint = [key]
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
with patch.dict(ssh_known_hosts.__opts__, {'test': True}):
with patch.object(os.path, 'isabs', MagicMock(retur... |
'Test to verifies that the specified host is not known by the given user.'
| def test_absent(self):
| name = 'github.com'
user = 'root'
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
with patch.object(os.path, 'isabs', MagicMock(return_value=False)):
comt = 'If not specifying a "user", specify an absolute "config".'
ret.update({'comment': comt... |
'Mock SetCategories'
| @staticmethod
def SetCategories(arg):
| return arg
|
'Mock SetIncludes'
| @staticmethod
def SetIncludes(arg):
| return arg
|
'Mock GetInstallationResults'
| @staticmethod
def GetInstallationResults():
| return True
|
'Mock GetDownloadResults'
| @staticmethod
def GetDownloadResults():
| return True
|
'Test to install specified windows updates'
| def test_installed(self):
| ret = {'name': 'salt', 'changes': {}, 'result': False, 'comment': '', 'warnings': ["The 'win_update' module is deprecated, and will be removed in Salt Fluorine. Please use the 'win_wua' module instead."]}
mock = MagicMock(side_effect=[['Saltstack', False, 5], [... |
'Test to cache updates for later install.'
| def test_downloaded(self):
| ret = {'name': 'salt', 'changes': {}, 'result': False, 'comment': '', 'warnings': ["The 'win_update' module is deprecated, and will be removed in Salt Fluorine. Please use the 'win_wua' module instead."]}
mock = MagicMock(side_effect=[['Saltstack', False, 5], [... |
'Test if none list changes handled correctly'
| def test_change_non_list_changes(self):
| comt = "'changes' must be specified as a list"
self.ret.update({'comment': comt})
self.assertDictEqual(augeas.change(self.name), self.ret)
|
'Test if none list load_path is handled correctly'
| def test_change_non_list_load_path(self):
| comt = "'load_path' must be specified as a list"
self.ret.update({'comment': comt})
self.assertDictEqual(augeas.change(self.name, self.context, self.changes, load_path='x'), self.ret)
|
'Test test mode handling'
| def test_change_in_test_mode(self):
| comt = 'Executing commands in file "/files/etc/services":\nins service-name after service-name[last()]\nset service-name[last()] zabbix-agent'
self.ret.update({'comment': comt, 'result': True})
with patch.dict(augeas.__opts__, {'test': True}):
self.assertDictEqual(augeas.c... |
'Test handling of no context without full path'
| def test_change_no_context_without_full_path(self):
| comt = 'Error: Changes should be prefixed with /files if no context is provided, change: {0}'.format(self.changes[0])
self.ret.update({'comment': comt, 'result': False})
with patch.dict(augeas.__opts__, {'test': False}):
mock_dict_ = {'augeas.method_map': self.... |
'Test handling of no context with full path with execute fail'
| def test_change_no_context_with_full_path_fail(self):
| self.ret.update({'comment': 'Error: error', 'result': False})
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=False, error='error'))
mock_dict_ = {'augeas.execute': mock_execute, 'augeas.method_map': self.mock_method_map}
with patch... |
'Test handling of no context with full path with execute pass'
| def test_change_no_context_with_full_path_pass(self):
| self.ret.update(dict(comment='Changes have been saved', result=True, changes={'diff': '+ zabbix-agent'}))
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=True))
mock_dict_ = {'augeas.execute': mock_execute, 'augeas.method_map': sel... |
'Test handling of invalid commands when no context supplied'
| def test_change_no_context_without_full_path_invalid_cmd(self):
| self.ret.update(dict(comment='Error: Command det is not supported (yet)', result=False))
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=True))
mock_dict_ = {'augeas.execute': mock_execute, 'augeas.method_map': self.mock_meth... |
'Test handling of invalid change when no context supplied'
| def test_change_no_context_without_full_path_invalid_change(self):
| comt = 'Error: Invalid formatted command, see debug log for details: require'
self.ret.update(dict(comment=comt, result=False))
changes = ['require']
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=True))
moc... |
'Test handling of different paths with no context supplied'
| def test_change_no_context_with_full_path_multiple_files(self):
| changes = ['set /files/etc/hosts/service-name test', 'set /files/etc/services/service-name test']
filename = '/etc/hosts/service-name'
filename_ = '/etc/services/service-name'
comt = 'Error: Changes should be made to one file at a time, detected changes ... |
'Test handling of context without full path fails'
| def test_change_with_context_without_full_path_fail(self):
| self.ret.update(dict(comment='Error: error', result=False))
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=False, error='error'))
mock_dict_ = {'augeas.execute': mock_execute, 'augeas.method_map': self.mock_method_map}
with patch.d... |
'Test handling of context without oldfile pass'
| def test_change_with_context_without_old_file(self):
| self.ret.update(dict(comment='Changes have been saved', result=True, changes={'updates': self.changes}))
with patch.dict(augeas.__opts__, {'test': False}):
mock_execute = MagicMock(return_value=dict(retval=True))
mock_dict_ = {'augeas.execute': mock_execute, 'augeas.method_map': self.mo... |
'Test to verifies the mode SELinux is running in,
can be set to enforcing or permissive.'
| def test_mode(self):
| ret = {'name': 'unknown', 'changes': {}, 'result': False, 'comment': 'unknown is not an accepted mode'}
self.assertDictEqual(selinux.mode('unknown'), ret)
mock_en = MagicMock(return_value='Enforcing')
mock_pr = MagicMock(side_effect=['Permissive', 'Enforcing'])
with patch.dict(selinux... |
'Test to set up an SELinux boolean.'
| def test_boolean(self):
| name = 'samba_create_home_dirs'
value = True
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
mock_en = MagicMock(return_value=[])
with patch.dict(selinux.__salt__, {'selinux.list_sebool': mock_en}):
comt = 'Boolean {0} is not available'.format(name)
re... |
'Test to allows for inputting a yaml dictionary into a file
for apache configuration files.'
| def test_configfile(self):
| with patch('os.path.exists', MagicMock(return_value=True)):
name = '/etc/distro/specific/apache.conf'
config = 'VirtualHost: this: "*:80"'
new_config = 'LiteralHost: that: "*:79"'
ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''}
with patch.object... |
'Test - Import the certificate file into the given certificate store.'
| def test_import_cert(self):
| kwargs = {'name': CERT_PATH}
ret = {'name': kwargs['name'], 'changes': {'old': None, 'new': THUMBPRINT}, 'comment': "Certificate '{0}' imported into store: {1}".format(THUMBPRINT, STORE_PATH), 'result': True}
mock_cache_file = MagicMock(return_value=CERT_PATH)
mock_certs = MagicMock(retur... |
'Test - Remove the certificate from the given certificate store.'
| def test_remove_cert(self):
| kwargs = {'name': 'remove-cert', 'thumbprint': THUMBPRINT}
ret = {'name': kwargs['name'], 'changes': {'old': kwargs['thumbprint'], 'new': None}, 'comment': "Certificate '{0}' removed from store: {1}".format(kwargs['thumbprint'], STORE_PATH), 'result': True}
mock_certs = MagicMock(return_value... |
'Test to device is monitored with Server Density.'
| def test_monitored(self):
| name = 'my_special_server'
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
mock_dict = MagicMock(return_value={'id': name})
mock_t = MagicMock(side_effect=[True, {'agentKey': True}, [{'agentKey': True}]])
mock_sd = MagicMock(side_effect=[['sd-agent'], [], True])
with patch.dic... |
'Test to verify options present in file.'
| def test_options_present(self):
| name = 'salt'
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
with patch.dict(ini_manage.__opts__, {'test': True}):
comt = 'No changes detected.'
ret.update({'comment': comt, 'result': True})
self.assertDictEqual(ini_manage.options_present(name), ret)
cha... |
'Test to verify options absent in file.'
| def test_options_absent(self):
| name = 'salt'
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
with patch.dict(ini_manage.__opts__, {'test': True}):
comt = 'No changes detected.'
ret.update({'comment': comt, 'result': True})
self.assertDictEqual(ini_manage.options_absent(name), ret)
with... |
'Test to verify sections present in file.'
| def test_sections_present(self):
| name = 'salt'
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
with patch.dict(ini_manage.__opts__, {'test': True}):
comt = 'No changes detected.'
ret.update({'comment': comt, 'result': True})
self.assertDictEqual(ini_manage.sections_present(name), ret)
ch... |
'Test to verify sections absent in file.'
| def test_sections_absent(self):
| name = 'salt'
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
with patch.dict(ini_manage.__opts__, {'test': True}):
comt = 'No changes detected.'
ret.update({'comment': comt, 'result': True})
self.assertDictEqual(ini_manage.sections_absent(name), ret)
wit... |
'Test capability installed state'
| def test_capability_installed(self):
| expected = {'comment': 'Installed Capa2', 'changes': {'capability': {'new': 'Capa2'}, 'retcode': 0}, 'name': 'Capa2', 'result': True}
mock_installed = MagicMock(side_effect=[['Capa1'], ['Capa1', 'Capa2']])
mock_add = MagicMock(return_value={'retcode': 0})
with patch.dict(dism.__salt__, {'dism.install... |
'Test installing a capability which fails with DISM'
| def test_capability_installed_failure(self):
| expected = {'comment': 'Failed to install Capa2: Failed', 'changes': {}, 'name': 'Capa2', 'result': False}
mock_installed = MagicMock(side_effect=[['Capa1'], ['Capa1']])
mock_add = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
with patch.dict(dism.__salt__, {'dism.installed_cap... |
'Test installing a capability already installed'
| def test_capability_installed_installed(self):
| expected = {'comment': 'The capability Capa2 is already installed', 'changes': {}, 'name': 'Capa2', 'result': True}
mock_installed = MagicMock(return_value=['Capa1', 'Capa2'])
mock_add = MagicMock()
with patch.dict(dism.__salt__, {'dism.installed_capabilities': mock_installed, 'dism.add_c... |
'Test capability removed state'
| def test_capability_removed(self):
| expected = {'comment': 'Removed Capa2', 'changes': {'capability': {'old': 'Capa2'}, 'retcode': 0}, 'name': 'Capa2', 'result': True}
mock_removed = MagicMock(side_effect=[['Capa1', 'Capa2'], ['Capa1']])
mock_remove = MagicMock(return_value={'retcode': 0})
with patch.dict(dism.__salt__, {'dism.installe... |
'Test removing a capability which fails with DISM'
| def test_capability_removed_failure(self):
| expected = {'comment': 'Failed to remove Capa2: Failed', 'changes': {}, 'name': 'Capa2', 'result': False}
mock_removed = MagicMock(side_effect=[['Capa1', 'Capa2'], ['Capa1', 'Capa2']])
mock_remove = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
with patch.dict(dism.__salt__, {'... |
'Test removing a capability already removed'
| def test_capability_removed_removed(self):
| expected = {'comment': 'The capability Capa2 is already removed', 'changes': {}, 'name': 'Capa2', 'result': True}
mock_removed = MagicMock(return_value=['Capa1'])
mock_remove = MagicMock()
with patch.dict(dism.__salt__, {'dism.installed_capabilities': mock_removed, 'dism.add_capability': ... |
'Test installing a feature with DISM'
| def test_feature_installed(self):
| expected = {'comment': 'Installed Feat2', 'changes': {'feature': {'new': 'Feat2'}, 'retcode': 0}, 'name': 'Feat2', 'result': True}
mock_installed = MagicMock(side_effect=[['Feat1'], ['Feat1', 'Feat2']])
mock_add = MagicMock(return_value={'retcode': 0})
with patch.dict(dism.__salt__, {'dism.installed_... |
'Test installing a feature which fails with DISM'
| def test_feature_installed_failure(self):
| expected = {'comment': 'Failed to install Feat2: Failed', 'changes': {}, 'name': 'Feat2', 'result': False}
mock_installed = MagicMock(side_effect=[['Feat1'], ['Feat1']])
mock_add = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
with patch.dict(dism.__salt__, {'dism.installed_fea... |
'Test installing a feature already installed'
| def test_feature_installed_installed(self):
| expected = {'comment': 'The feature Feat1 is already installed', 'changes': {}, 'name': 'Feat1', 'result': True}
mock_installed = MagicMock(side_effect=[['Feat1', 'Feat2'], ['Feat1', 'Feat2']])
mock_add = MagicMock()
with patch.dict(dism.__salt__, {'dism.installed_features': mock_installe... |
'Test removing a feature with DISM'
| def test_feature_removed(self):
| expected = {'comment': 'Removed Feat2', 'changes': {'feature': {'old': 'Feat2'}, 'retcode': 0}, 'name': 'Feat2', 'result': True}
mock_removed = MagicMock(side_effect=[['Feat1', 'Feat2'], ['Feat1']])
mock_remove = MagicMock(return_value={'retcode': 0})
with patch.dict(dism.__salt__, {'dism.installed_f... |
'Test removing a feature which fails with DISM'
| def test_feature_removed_failure(self):
| expected = {'comment': 'Failed to remove Feat2: Failed', 'changes': {}, 'name': 'Feat2', 'result': False}
mock_removed = MagicMock(side_effect=[['Feat1', 'Feat2'], ['Feat1', 'Feat2']])
mock_remove = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
with patch.dict(dism.__salt__, {'... |
'Test removing a feature already removed'
| def test_feature_removed_removed(self):
| expected = {'comment': 'The feature Feat2 is already removed', 'changes': {}, 'name': 'Feat2', 'result': True}
mock_removed = MagicMock(side_effect=[['Feat1'], ['Feat1']])
mock_remove = MagicMock()
with patch.dict(dism.__salt__, {'dism.installed_features': mock_removed, 'dism.remove_featu... |
'Test installing a package with DISM'
| def test_package_installed(self):
| expected = {'comment': 'Installed Pack2', 'changes': {'package': {'new': 'Pack2'}, 'retcode': 0}, 'name': 'Pack2', 'result': True}
mock_installed = MagicMock(side_effect=[['Pack1'], ['Pack1', 'Pack2']])
mock_add = MagicMock(return_value={'retcode': 0})
mock_info = MagicMock(return_value={'Package ... |
'Test installing a package which fails with DISM'
| def test_package_installed_failure(self):
| expected = {'comment': 'Failed to install Pack2: Failed', 'changes': {}, 'name': 'Pack2', 'result': False}
mock_installed = MagicMock(side_effect=[['Pack1'], ['Pack1']])
mock_add = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
mock_info = MagicMock(return_value={'Package Ide... |
'Test installing a package already installed'
| def test_package_installed_installed(self):
| expected = {'comment': 'The package Pack2 is already installed: Pack2', 'changes': {}, 'name': 'Pack2', 'result': True}
mock_installed = MagicMock(side_effect=[['Pack1', 'Pack2'], ['Pack1', 'Pack2']])
mock_add = MagicMock()
mock_info = MagicMock(return_value={'Package Identity': 'Pa... |
'Test removing a package with DISM'
| def test_package_removed(self):
| expected = {'comment': 'Removed Pack2', 'changes': {'package': {'old': 'Pack2'}, 'retcode': 0}, 'name': 'Pack2', 'result': True}
mock_removed = MagicMock(side_effect=[['Pack1', 'Pack2'], ['Pack1']])
mock_remove = MagicMock(return_value={'retcode': 0})
mock_info = MagicMock(return_value={'Package I... |
'Test removing a package which fails with DISM'
| def test_package_removed_failure(self):
| expected = {'comment': 'Failed to remove Pack2: Failed', 'changes': {}, 'name': 'Pack2', 'result': False}
mock_removed = MagicMock(side_effect=[['Pack1', 'Pack2'], ['Pack1', 'Pack2']])
mock_remove = MagicMock(return_value={'retcode': 67, 'stdout': 'Failed'})
mock_info = MagicMock(return_valu... |
'Test removing a package already removed'
| def test_package_removed_removed(self):
| expected = {'comment': 'The package Pack2 is already removed', 'changes': {}, 'name': 'Pack2', 'result': True}
mock_removed = MagicMock(side_effect=[['Pack1'], ['Pack1']])
mock_remove = MagicMock()
mock_info = MagicMock(return_value={'Package Identity': 'Pack2'})
with patch.dict(di... |
'Test to ensure the user exists on the Dell DRAC'
| def test_present(self):
| name = 'damian'
password = 'secret'
permission = 'login,test_alerts,clear_logs'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock = MagicMock(return_value=[name])
with patch.dict(drac.__salt__, {'drac.list_users': mock}):
with patch.dict(drac.__opts__, {'test': True... |
'Test to ensure a user does not exist on the Dell DRAC'
| def test_absent(self):
| name = 'damian'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock = MagicMock(return_value=[])
with patch.dict(drac.__salt__, {'drac.list_users': mock}):
with patch.dict(drac.__opts__, {'test': True}):
comt = '`{0}` does not exist'.format(name)
... |
'Test to ensure the DRAC network settings are consistent'
| def test_network(self):
| ip_ = '10.225.108.29'
netmask = '255.255.255.224'
gateway = '10.225.108.1'
ret = {'name': ip_, 'result': None, 'comment': '', 'changes': {}}
net_info = {'IPv4 settings': {'IP Address': ip_, 'Subnet Mask': netmask, 'Gateway': gateway}}
mock_info = MagicMock(return_value=net_info)
moc... |
'Test to ensure that the specified kernel module is loaded.'
| def test_present(self):
| name = 'cheese'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock_mod_list = MagicMock(return_value=[name])
with patch.dict(kmod.__salt__, {'kmod.mod_list': mock_mod_list}):
comment = 'Kernel module {0} is already present'.format(name)
ret.update({'co... |
'Test to ensure that multiple kernel modules are loaded.'
| def test_present_multi(self):
| name = 'salted kernel'
mods = ['cheese', 'crackers']
ret = {'name': name, 'result': True, 'changes': {}}
mock_mod_list = MagicMock(return_value=mods)
with patch.dict(kmod.__salt__, {'kmod.mod_list': mock_mod_list}):
call_ret = kmod.present(name, mods=mods)
comment = call_ret.pop('... |
'Test to verify that the named kernel module is not loaded.'
| def test_absent(self):
| name = 'cheese'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock_mod_list = MagicMock(return_value=[name])
with patch.dict(kmod.__salt__, {'kmod.mod_list': mock_mod_list}):
with patch.dict(kmod.__opts__, {'test': True}):
comment = 'Kernel module {0} is... |
'Test to verify that multiple kernel modules are not loaded.'
| def test_absent_multi(self):
| name = 'salted kernel'
mods = ['cheese', 'crackers']
ret = {'name': name, 'result': True, 'changes': {}}
mock_mod_list = MagicMock(return_value=mods)
with patch.dict(kmod.__salt__, {'kmod.mod_list': mock_mod_list}):
with patch.dict(kmod.__opts__, {'test': True}):
ret.update({'... |
'Test to verify the chain is exist.'
| def test_chain_present(self):
| ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''}
mock = MagicMock(side_effect=[True, False, False, False])
with patch.dict(iptables.__salt__, {'iptables.check_chain': mock}):
ret.update({'comment': 'iptables salt chain is already exist in filter table f... |
'Test to verify the chain is absent.'
| def test_chain_absent(self):
| ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''}
mock = MagicMock(side_effect=[False, True, True, True])
with patch.dict(iptables.__salt__, {'iptables.check_chain': mock}):
ret.update({'comment': 'iptables salt chain is already absent in filter table fo... |
'Test to append a rule to a chain'
| def test_append(self):
| ret = {'name': 'salt', 'changes': {}, 'result': None, 'comment': ''}
self.assertDictEqual(iptables.append('salt', rules=[]), ret)
mock = MagicMock(return_value=[])
with patch.object(iptables, '_STATE_INTERNAL_KEYWORDS', mock):
mock = MagicMock(return_value='a')
with patch.dict(iptables._... |
'Test to insert a rule into a chain'
| def test_insert(self):
| ret = {'name': 'salt', 'changes': {}, 'result': None, 'comment': ''}
self.assertDictEqual(iptables.insert('salt', rules=[]), ret)
mock = MagicMock(return_value=[])
with patch.object(iptables, '_STATE_INTERNAL_KEYWORDS', mock):
mock = MagicMock(return_value='a')
with patch.dict(iptables._... |
'Test to delete a rule to a chain'
| def test_delete(self):
| ret = {'name': 'salt', 'changes': {}, 'result': None, 'comment': ''}
self.assertDictEqual(iptables.delete('salt', rules=[]), ret)
mock = MagicMock(return_value=[])
with patch.object(iptables, '_STATE_INTERNAL_KEYWORDS', mock):
mock = MagicMock(return_value='a')
with patch.dict(iptables._... |
'Test to sets the default policy for iptables firewall tables'
| def test_set_policy(self):
| ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''}
mock = MagicMock(return_value=[])
with patch.object(iptables, '_STATE_INTERNAL_KEYWORDS', mock):
mock = MagicMock(return_value='stack')
with patch.dict(iptables.__salt__, {'iptables.get_policy': mock}):
ret.upda... |
'Test to flush current iptables state'
| def test_flush(self):
| ret = {'name': 'salt', 'changes': {}, 'result': None, 'comment': ''}
mock = MagicMock(return_value=[])
with patch.object(iptables, '_STATE_INTERNAL_KEYWORDS', mock):
with patch.dict(iptables.__opts__, {'test': True}):
ret.update({'comment': 'iptables rules in salt table fi... |
'Test to mod_aggregate function'
| def test_mod_aggregate(self):
| self.assertDictEqual(iptables.mod_aggregate({'fun': 'salt'}, [], []), {'fun': 'salt'})
self.assertDictEqual(iptables.mod_aggregate({'fun': 'append'}, [], []), {'fun': 'append'})
|
'Test to verify that the overlay is present.'
| def test_present(self):
| name = 'sunrise'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock = MagicMock(side_effect=[[name], []])
with patch.dict(layman.__salt__, {'layman.list_local': mock}):
comt = 'Overlay {0} already present'.format(name)
ret.update({'comment': comt})
s... |
'Test to verify that the overlay is absent.'
| def test_absent(self):
| name = 'sunrise'
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
mock = MagicMock(side_effect=[[], [name]])
with patch.dict(layman.__salt__, {'layman.list_local': mock}):
comt = 'Overlay {0} already absent'.format(name)
ret.update({'comment': comt})
se... |
'Test to make sure we can set the proxy settings on macOS'
| def test_set_proxy_macos(self):
| with patch.dict(proxy.__grains__, {'os': 'Darwin'}):
expected = {'changes': {'new': [{'port': '3128', 'server': '192.168.0.1', 'service': 'http', 'user': 'frank'}, {'port': '3128', 'server': '192.168.0.1', 'service': 'https', 'user': 'frank'}, {'port': '3128', 'server': '192.168.0.1', 'service': 'ftp', 'use... |
'Test to make sure we can set the proxy settings on macOS'
| def test_set_proxy_macos_same(self):
| with patch.dict(proxy.__grains__, {'os': 'Darwin'}):
expected = {'changes': {}, 'comment': 'http proxy settings already set.\nhttps proxy settings already set.\nftp proxy settings already set.\nProxy bypass domains are already set correctly.\n', 'name': ... |
'Test to make sure we can set the proxy settings on Windows'
| def test_set_proxy_windows(self):
| with patch.dict(proxy.__grains__, {'os': 'Windows'}):
expected = {'changes': {}, 'comment': 'Proxy settings updated correctly', 'name': '192.168.0.1', 'result': True}
set_proxy_mock = MagicMock(return_value=True)
patches = {'proxy.get_proxy_win': MagicMock(return_value={}), 'proxy.g... |
'Test to make sure we can set the proxy settings on Windows'
| def test_set_proxy_windows_same(self):
| with patch.dict(proxy.__grains__, {'os': 'Windows'}):
expected = {'changes': {}, 'comment': 'Proxy settings already correct.', 'name': '192.168.0.1', 'result': True}
proxy_val = {'enabled': True, 'http': {'enabled': True, 'server': '192.168.0.1', 'port': '3128'}, 'https': {'enabled': True, ... |
'Tests present on a function that does not exist.'
| def test_present_when_function_does_not_exist(self):
| self.conn.list_functions.side_effect = [{'Functions': []}, {'Functions': [function_ret]}]
self.conn.create_function.return_value = function_ret
with patch.dict(self.funcs, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
with TempZipFile() as zipfile:
result = self.salt_stat... |
'Tests absent on a function that does not exist.'
| def test_absent_when_function_does_not_exist(self):
| self.conn.list_functions.return_value = {'Functions': [function_ret]}
result = self.salt_states['boto_lambda.function_absent']('test', 'myfunc')
self.assertTrue(result['result'])
self.assertEqual(result['changes'], {})
|
'Tests present on a alias that does not exist.'
| def test_present_when_alias_does_not_exist(self):
| self.conn.list_aliases.side_effect = [{'Aliases': []}, {'Aliases': [alias_ret]}]
self.conn.create_alias.return_value = alias_ret
result = self.salt_states['boto_lambda.alias_present']('alias present', FunctionName='testfunc', Name=alias_ret['Name'], FunctionVersion=alias_ret['FunctionVersion'])
self.... |
'Tests absent on a alias that does not exist.'
| def test_absent_when_alias_does_not_exist(self):
| self.conn.list_aliases.return_value = {'Aliases': [alias_ret]}
result = self.salt_states['boto_lambda.alias_absent']('alias absent', FunctionName='testfunc', Name='myalias')
self.assertTrue(result['result'])
self.assertEqual(result['changes'], {})
|
'Tests present on a event_source_mapping that does not exist.'
| def test_present_when_event_source_mapping_does_not_exist(self):
| self.conn.list_event_source_mappings.side_effect = [{'EventSourceMappings': []}, {'EventSourceMappings': [event_source_mapping_ret]}]
self.conn.get_event_source_mapping.return_value = event_source_mapping_ret
self.conn.create_event_source_mapping.return_value = event_source_mapping_ret
result = self.sal... |
'Tests absent on a event_source_mapping that does not exist.'
| def test_absent_when_event_source_mapping_does_not_exist(self):
| self.conn.list_event_source_mappings.return_value = {'EventSourceMappings': []}
result = self.salt_states['boto_lambda.event_source_mapping_absent']('event source mapping absent', EventSourceArn=event_source_mapping_ret['EventSourceArn'], FunctionName='myfunc')
self.assertTrue(result['result'])
... |
'Test docker_volume.present'
| def test_present(self):
| volumes = []
default_driver = 'dummy_default'
def create_volume(name, driver=None, driver_opts=None):
for v in volumes:
self.assertNotEqual(v['Name'], name)
if (driver is None):
driver = default_driver
new = {'Name': name, 'Driver': driver}
volumes.app... |
'Test docker_volume.present'
| def test_present_with_another_driver(self):
| docker_create_volume = Mock(return_value='created')
docker_remove_volume = Mock(return_value='removed')
__salt__ = {'docker.create_volume': docker_create_volume, 'docker.remove_volume': docker_remove_volume, 'docker.volumes': Mock(return_value={'Volumes': [{'Name': 'volume_foo', 'Driver': 'foo'}]})}
wit... |
'Test docker_volume.present without existing volumes.'
| def test_present_wo_existing_volumes(self):
| docker_create_volume = Mock(return_value='created')
docker_remove_volume = Mock(return_value='removed')
__salt__ = {'docker.create_volume': docker_create_volume, 'docker.remove_volume': docker_remove_volume, 'docker.volumes': Mock(return_value={'Volumes': None})}
with patch.dict(docker_state.__dict__, {... |
'Test docker_volume.absent'
| def test_absent(self):
| docker_remove_volume = Mock(return_value='removed')
__salt__ = {'docker.remove_volume': docker_remove_volume, 'docker.volumes': Mock(return_value={'Volumes': [{'Name': 'volume_foo'}]})}
with patch.dict(docker_state.__dict__, {'__salt__': __salt__}):
ret = docker_state.absent('volume_foo')
docker... |
'Test to ensure the current node joined
to a cluster with node user@host'
| def test_joined(self):
| ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''}
mock = MagicMock(side_effect=[['rahulha@salt'], [''], ['']])
with patch.dict(rabbitmq_cluster.__salt__, {'rabbitmq.cluster_status': mock}):
ret.update({'comment': 'Already in cluster'})
self.assertDictEqual(rabbitmq_c... |
'Test to set a registry entry.'
| def test_present(self):
| name = 'HKEY_CURRENT_USER\\SOFTWARE\\Salt'
vname = 'version'
vdata = '0.15.3'
ret = {'name': name, 'changes': {}, 'result': True, 'comment': '{0} in {1} is already configured'.format(vname, name)}
mock_read = MagicMock(side_effect=[{'vdata': vdata, 'success': True}, {'vdata': 'a', 'su... |
'Test to remove a registry entry.'
| def test_absent(self):
| hive = 'HKEY_CURRENT_USER'
key = 'SOFTWARE\\Salt'
name = ((hive + '\\') + key)
vname = 'version'
vdata = '0.15.3'
ret = {'name': name, 'changes': {}, 'result': True, 'comment': '{0} is already absent'.format(name)}
mock_read_true = MagicMock(return_value={'success': True, 'vdata': v... |
'Test to stop the named worker from the lbn load balancers
at the targeted minions.'
| def test_stop(self):
| name = "{{ grains['id'] }}"
lbn = 'application'
target = 'roles:balancer'
ret = {'name': name, 'result': False, 'comment': '', 'changes': {}}
comt = 'no servers answered the published command modjk.worker_status'
mock = MagicMock(return_value=False)
with patch.dict(mo... |
'Test to activate the named worker from the lbn load balancers
at the targeted minions.'
| def test_activate(self):
| name = "{{ grains['id'] }}"
lbn = 'application'
target = 'roles:balancer'
ret = {'name': name, 'result': False, 'comment': '', 'changes': {}}
comt = 'no servers answered the published command modjk.worker_status'
mock = MagicMock(return_value=False)
with patch.dict(mo... |
'Test to disable the named worker from the lbn load balancers
at the targeted minions.'
| def test_disable(self):
| name = "{{ grains['id'] }}"
lbn = 'application'
target = 'roles:balancer'
ret = {'name': name, 'result': False, 'comment': '', 'changes': {}}
comt = 'no servers answered the published command modjk.worker_status'
mock = MagicMock(return_value=False)
with patch.dict(mo... |
'Test to ensure that the named database is present
with the specified properties.'
| def test_present(self):
| name = 'main'
version = '9.4'
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
mock_t = MagicMock(return_value=True)
mock_f = MagicMock(return_value=False)
infos = {'{0}/{1}'.format(version, name): {}}
mock = MagicMock(return_value=infos)
with patch.dict(postgres_clust... |
'Test to ensure that the named database is absent.'
| def test_absent(self):
| name = 'main'
version = '9.4'
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
mock_t = MagicMock(return_value=True)
mock = MagicMock(side_effect=[True, True, False])
with patch.dict(postgres_cluster.__salt__, {'postgres.cluster_exists': mock, 'postgres.cluster_remove': mock_t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.