desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Test to clean the version string removing extra data.'
| def test_version_clean(self):
| with patch.dict(pkg_resource.__salt__, {'pkg.version_clean': MagicMock(return_value='A')}):
self.assertEqual(pkg_resource.version_clean('version'), 'A')
self.assertEqual(pkg_resource.version_clean('v'), 'v')
|
'Test to check if the installed package already
has the given requirements.'
| def test_check_extra_requirements(self):
| with patch.dict(pkg_resource.__salt__, {'pkg.check_extra_requirements': MagicMock(return_value='A')}):
self.assertEqual(pkg_resource.check_extra_requirements('a', 'b'), 'A')
self.assertTrue(pkg_resource.check_extra_requirements('a', False))
|
'Tests return the hosts found in the hosts file'
| def test_list_hosts(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
self.assertDictEqual({'10.10.10.10': ['Salt1', 'Salt2']}, hosts.list_hosts())
|
'Tests return ip associated with the named host'
| def test_get_ip(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
self.assertEqual('10.10.10.10', hosts.get_ip('Salt1'))
self.assertEqual('', hosts.get_ip('Salt3'))
|
'Tests return ip associated with the named host'
| def test_get_ip_none(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value='')):
self.assertEqual('', hosts.get_ip('Salt1'))
|
'Tests return the list of aliases associated with an ip'
| def test_get_alias(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
self.assertListEqual(['Salt1', 'Salt2'], hosts.get_alias('10.10.10.10'))
|
'Tests return the list of aliases associated with an ip'
| def test_get_alias_none(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
self.assertListEqual([], hosts.get_alias('10.10.10.11'))
|
'Tests return True / False if the alias is set'
| def test_has_pair(self):
| with patch('salt.modules.hosts._list_hosts', MagicMock(return_value={'10.10.10.10': ['Salt1', 'Salt2']})):
self.assertTrue(hosts.has_pair('10.10.10.10', 'Salt1'))
self.assertFalse(hosts.has_pair('10.10.10.10', 'Salt3'))
|
'Tests true if the alias is set'
| def test_set_host(self):
| with patch('salt.modules.hosts.__get_hosts_filename', MagicMock(return_value='/etc/hosts')):
with patch('os.path.isfile', MagicMock(return_value=False)):
with patch.dict(hosts.__salt__, {'config.option': MagicMock(return_value=None)}):
self.assertFalse(hosts.set_host('10.10.10.10... |
'Tests true if the alias is set'
| def test_set_host_true(self):
| with patch('salt.modules.hosts.__get_hosts_filename', MagicMock(return_value='/etc/hosts')):
with patch('os.path.isfile', MagicMock(return_value=True)):
with patch('salt.utils.files.fopen', mock_open()):
mock_opt = MagicMock(return_value=None)
with patch.dict(host... |
'Test if an empty hosts value removes existing entries'
| def test_set_host_true_remove(self):
| with patch('salt.modules.hosts.__get_hosts_filename', MagicMock(return_value='/etc/hosts')):
with patch('os.path.isfile', MagicMock(return_value=True)):
data = ['\n'.join(('1.1.1.1 foo.foofoo foo', '2.2.2.2 bar.barbar bar', '3.3.3.3 asdf.asdfadsf asdf', '1.1.1.1 foofoo.foofo... |
'Tests if specified host entry gets removed from the hosts file'
| def test_rm_host(self):
| with patch('salt.utils.files.fopen', mock_open()):
with patch('salt.modules.hosts.__get_hosts_filename', MagicMock(return_value='/etc/hosts')):
with patch('salt.modules.hosts.has_pair', MagicMock(return_value=True)):
with patch('os.path.isfile', MagicMock(return_value=True)):
... |
'Tests if specified host entry gets removed from the hosts file'
| def test_rm_host_false(self):
| with patch('salt.modules.hosts.has_pair', MagicMock(return_value=False)):
self.assertTrue(hosts.rm_host('10.10.10.10', 'Salt1'))
|
'Tests if specified host entry gets added from the hosts file'
| def test_add_host(self):
| with patch('salt.utils.files.fopen', mock_open()):
with patch('salt.modules.hosts.__get_hosts_filename', MagicMock(return_value='/etc/hosts')):
mock_opt = MagicMock(return_value=None)
with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
self.assertTrue(hosts.... |
'Tests if specified host entry gets added from the hosts file'
| def test_add_host_no_file(self):
| with patch('salt.utils.files.fopen', mock_open()):
with patch('os.path.isfile', MagicMock(return_value=False)):
mock_opt = MagicMock(return_value=None)
with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
self.assertFalse(hosts.add_host('10.10.10.10', 'Salt1'... |
'Tests if specified host entry gets added from the hosts file'
| def test_add_host_create_entry(self):
| with patch('salt.utils.files.fopen', mock_open()):
with patch('os.path.isfile', MagicMock(return_value=True)):
mock_opt = MagicMock(return_value=None)
with patch.dict(hosts.__salt__, {'config.option': mock_opt}):
self.assertTrue(hosts.add_host('10.10.10.10', 'Salt1'))... |
'Test if it purge all the jobs currently scheduled on the minion.'
| def test_purge(self):
| with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'complete': True, 'schedule': {}}
with patch.object(SaltEvent, 'get_event', return_value=_re... |
'Test if it delete a job from the minion\'s schedule.'
| def test_delete(self):
| with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'complete': True, 'schedule': {}}
with patch.object(SaltEvent, 'get_event', return_value=_re... |
'Test if it build a schedule job.'
| def test_build_schedule_item(self):
| comment = 'Unable to use "seconds", "minutes", "hours", or "days" with "when" or "cron" options.'
comment1 = 'Unable to use "when" and "cron" options together. Ignoring.'
with patch.dict(schedule.__opts__, {'job1': {}}):
self.assertDict... |
'Test if it add a job to the schedule.'
| def test_add(self):
| comm1 = 'Job job1 already exists in schedule.'
comm2 = 'Error: Unable to use "seconds", "minutes", "hours", or "days" with "when" or "cron" options.'
comm3 = 'Unable to use "when" and "cron" options together. Ignoring.'
co... |
'Test if it run a scheduled job on the minion immediately.'
| def test_run_job(self):
| with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'complete': True, 'schedule': {}}
with patch.object(SaltEvent, 'get_event', return_value=_re... |
'Test if it enable a job in the minion\'s schedule.'
| def test_enable_job(self):
| with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'complete': True, 'schedule': {}}
with patch.object(SaltEvent, 'get_event', return_value=_re... |
'Test if it disable a job in the minion\'s schedule.'
| def test_disable_job(self):
| with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'complete': True, 'schedule': {}}
with patch.object(SaltEvent, 'get_event', return_value=_re... |
'Test if it save all scheduled jobs on the minion.'
| def test_save(self):
| comm1 = 'Schedule (non-pillar items) saved.'
with patch.dict(schedule.__opts__, {'config_dir': '', 'schedule': {}, 'default_include': '/tmp', 'sock_dir': SOCK_DIR}):
mock = MagicMock(return_value=True)
with patch.dict(schedule.__salt__, {'event.fire': mock}):
_ret_value = {'... |
'Test if it enable all scheduled jobs on the minion.'
| def test_enable(self):
| self.assertDictEqual(schedule.enable(test=True), {'comment': 'Schedule would be enabled.', 'result': True})
|
'Test if it disable all scheduled jobs on the minion.'
| def test_disable(self):
| self.assertDictEqual(schedule.disable(test=True), {'comment': 'Schedule would be disabled.', 'result': True})
|
'Test if it move scheduled job to another minion or minions.'
| def test_move(self):
| comm1 = 'no servers answered the published schedule.add command'
comm2 = 'the following minions return False'
comm3 = 'Moved Job job1 from schedule.'
with patch.dict(schedule.__opts__, {'schedule': {'job1': JOB1}, 'sock_dir': SOCK_DIR}):
mock = MagicMock... |
'Test if it copy scheduled job to another minion or minions.'
| def test_copy(self):
| comm1 = 'no servers answered the published schedule.add command'
comm2 = 'the following minions return False'
comm3 = 'Copied Job job1 from schedule to minion(s).'
with patch.dict(schedule.__opts__, {'schedule': {'job1': JOB1}, 'sock_dir': SOCK_DIR}):
... |
'Test if it performs a ping to a host.'
| def test_ping(self):
| mock = MagicMock(return_value=True)
with patch.dict(win_network.__salt__, {'cmd.run': mock}):
self.assertTrue(win_network.ping('127.0.0.1'))
|
'Test if it return information on open ports and states'
| def test_netstat(self):
| ret = ' Proto Local Address Foreign Address State PID\n TCP 127.0.0.1:1434 0.0.0.0:0 LISTENING 1728\n UDP 127.0.0.1:1900 *:* ... |
'Test if it performs a traceroute to a 3rd party host'
| def test_traceroute(self):
| ret = ' 1 1 ms <1 ms <1 ms 172.27.104.1\n 2 1 ms <1 ms 1 ms 121.242.35.1.s[121.242.35.1]\n 3 3 ms 2 ms ... |
'Test if it query DNS for information about a domain or ip address'
| def test_nslookup(self):
| ret = 'Server: ct-dc-3-2.cybage.com\nAddress: 172.27.172.12\nNon-authoritative answer:\nName: google.com\nAddresses: 2404:6800:4007:806::200e\n216.58.196.110\n'
mock = MagicMock(return_value=ret)
with patch.dict(win_network.__salt__, {'cmd.run': mock}):
self.as... |
'Test if it performs a DNS lookup with dig'
| def test_dig(self):
| mock = MagicMock(return_value=True)
with patch.dict(win_network.__salt__, {'cmd.run': mock}):
self.assertTrue(win_network.dig('google.com'))
|
'Test if it return a list of all the interfaces names'
| def test_interfaces_names(self):
| self.WMI.Win32_NetworkAdapter = MagicMock(return_value=Mockwmi)
with patch('salt.utils.winapi.Com', MagicMock()):
with patch.object(self.WMI, 'Win32_NetworkAdapter', return_value=[Mockwmi()]):
with patch('salt.utils', Mockwinapi):
self.assertListEqual(win_network.interfaces_n... |
'Test if it return information about all the interfaces on the minion'
| def test_interfaces(self):
| with patch.object(salt.utils.network, 'win_interfaces', MagicMock(return_value=True)):
self.assertTrue(win_network.interfaces())
|
'Test if it return the hardware address (a.k.a. MAC address)
for a given interface'
| def test_hw_addr(self):
| with patch.object(salt.utils.network, 'hw_addr', MagicMock(return_value='Ethernet')):
self.assertEqual(win_network.hw_addr('Ethernet'), 'Ethernet')
|
'Test if it returns a list of subnets to which the host belongs'
| def test_subnets(self):
| with patch.object(salt.utils.network, 'subnets', MagicMock(return_value='10.1.1.0/24')):
self.assertEqual(win_network.subnets(), '10.1.1.0/24')
|
'Test if it returns True if host is within specified subnet,
otherwise False'
| def test_in_subnet(self):
| with patch.object(salt.utils.network, 'in_subnet', MagicMock(return_value=True)):
self.assertTrue(win_network.in_subnet('10.1.1.0/16'))
|
'Test if it return information on open ports and states'
| def test_get_route(self):
| ret = '\n\nIPAddress : 10.0.0.15\nInterfaceIndex : 3\nInterfaceAlias : Wi-Fi\nAddressFamily : IPv4\nType : Unicast\nPrefixLength : 24\nP... |
'Test for Get all mine data for \'docker.ps\' and run an
aggregation.'
| def test_get_docker(self):
| ps_response = {'localhost': {'host': {'interfaces': {'docker0': {'hwaddr': '88:99:00:00:99:99', 'inet': [{'address': '172.17.42.1', 'broadcast': None, 'label': 'docker0', 'netmask': '255.255.0.0'}], 'inet6': [{'address': 'ffff::eeee:aaaa:bbbb:8888', 'prefixlen': '64'}], 'up': True}, 'eth0': {'hwaddr': '88:99:00:99:... |
'Test for Get all mine data for \'docker.ps\' and run an
aggregation.'
| def test_get_docker_with_container_id(self):
| ps_response = {'localhost': {'host': {'interfaces': {'docker0': {'hwaddr': '88:99:00:00:99:99', 'inet': [{'address': '172.17.42.1', 'broadcast': None, 'label': 'docker0', 'netmask': '255.255.0.0'}], 'inet6': [{'address': 'ffff::eeee:aaaa:bbbb:8888', 'prefixlen': '64'}], 'up': True}, 'eth0': {'hwaddr': '88:99:00:99:... |
'Test xattr.list'
| def test_list(self):
| expected = {'spongebob': 'squarepants', 'squidward': 'patrick'}
with patch.object(xattr, 'read', MagicMock(side_effect=['squarepants', 'patrick'])):
with patch('salt.utils.mac_utils.execute_return_result', MagicMock(return_value='spongebob\nsquidward')):
self.assertEqual(xattr.list_('path/to... |
'Test listing attributes of a missing file'
| def test_list_missing(self):
| with patch('salt.utils.mac_utils.execute_return_result', MagicMock(side_effect=CommandExecutionError('No such file'))):
self.assertRaises(CommandExecutionError, xattr.list_, '/path/to/file')
|
'Test reading a specific attribute from a file'
| def test_read(self):
| with patch('salt.utils.mac_utils.execute_return_result', MagicMock(return_value='expected results')):
self.assertEqual(xattr.read('/path/to/file', 'com.attr'), 'expected results')
|
'Test reading a specific attribute from a file'
| def test_read_hex(self):
| with patch.object(salt.utils.mac_utils, 'execute_return_result', MagicMock(return_value='expected results')) as mock:
self.assertEqual(xattr.read('/path/to/file', 'com.attr', **{'hex': True}), 'expected results')
mock.assert_called_once_with(['xattr', '-p', '-x', 'com.attr', '/path/to/file'])
|
'Test reading a specific attribute from a file'
| def test_read_missing(self):
| with patch('salt.utils.mac_utils.execute_return_result', MagicMock(side_effect=CommandExecutionError('No such file'))):
self.assertRaises(CommandExecutionError, xattr.read, '/path/to/file', 'attribute')
|
'Test writing a specific attribute to a file'
| def test_write(self):
| mock_cmd = MagicMock(return_value='squarepants')
with patch.object(xattr, 'read', mock_cmd):
with patch('salt.utils.mac_utils.execute_return_success', MagicMock(return_value=True)):
self.assertTrue(xattr.write('/path/to/file', 'spongebob', 'squarepants'))
|
'Test writing a specific attribute to a file'
| def test_write_missing(self):
| with patch('salt.utils.mac_utils.execute_return_success', MagicMock(side_effect=CommandExecutionError('No such file'))):
self.assertRaises(CommandExecutionError, xattr.write, '/path/to/file', 'attribute', 'value')
|
'Test deleting a specific attribute from a file'
| def test_delete(self):
| mock_cmd = MagicMock(return_value={'spongebob': 'squarepants'})
with patch.object(xattr, 'list_', mock_cmd):
with patch('salt.utils.mac_utils.execute_return_success', MagicMock(return_value=True)):
self.assertTrue(xattr.delete('/path/to/file', 'attribute'))
|
'Test deleting a specific attribute from a file'
| def test_delete_missing(self):
| with patch('salt.utils.mac_utils.execute_return_success', MagicMock(side_effect=CommandExecutionError('No such file'))):
self.assertRaises(CommandExecutionError, xattr.delete, '/path/to/file', 'attribute')
|
'Test clearing all attributes on a file'
| def test_clear(self):
| mock_cmd = MagicMock(return_value={})
with patch.object(xattr, 'list_', mock_cmd):
with patch('salt.utils.mac_utils.execute_return_success', MagicMock(return_value=True)):
self.assertTrue(xattr.clear('/path/to/file'))
|
'Test clearing all attributes on a file'
| def test_clear_missing(self):
| with patch('salt.utils.mac_utils.execute_return_success', MagicMock(side_effect=CommandExecutionError('No such file'))):
self.assertRaises(CommandExecutionError, xattr.clear, '/path/to/file')
|
'Test if it execute a chef client run and return a dict'
| def test_client(self):
| self.assertDictEqual(chef.client(), {})
|
'Test if it execute a chef solo run and return a dict'
| def test_solo(self):
| self.assertDictEqual(chef.solo('/dev/sda1'), {})
|
'Test - Return return the latest installed kernel version'
| def test_list_installed(self):
| PACKAGE_LIST = ['{0}-{1}'.format(kernelpkg._package_prefix(), kernel) for kernel in self.KERNEL_LIST]
mock = MagicMock(return_value=PACKAGE_LIST)
with patch.dict(self._kernelpkg.__salt__, {'pkg.list_pkgs': mock}):
self.assertListEqual(self._kernelpkg.list_installed(), self.KERNEL_LIST)
|
'Test - Return return the latest installed kernel version'
| def test_list_installed_none(self):
| mock = MagicMock(return_value=None)
with patch.dict(self._kernelpkg.__salt__, {'pkg.list_pkgs': mock}):
self.assertListEqual(self._kernelpkg.list_installed(), [])
|
'Test if it install pyenv systemwide'
| def test_install(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_ret = MagicMock(return_value=0)
with patch.dict(pyenv.__salt__, {'config.option': mock_opt, 'cmd.retcode': mock_ret}):
self.assertTrue(pyenv.install())
|
'Test if it updates the current versions of pyenv and python-Build'
| def test_update(self):
| mock_opt = MagicMock(return_value='salt stack')
with patch.dict(pyenv.__salt__, {'config.option': mock_opt}):
self.assertFalse(pyenv.update())
|
'Test if it check if pyenv is installed.'
| def test_is_installed(self):
| mock_cmd = MagicMock(return_value=True)
mock_opt = MagicMock(return_value='salt stack')
with patch.dict(pyenv.__salt__, {'config.option': mock_opt, 'cmd.has_exec': mock_cmd}):
self.assertTrue(pyenv.is_installed())
|
'Test if it install a python implementation.'
| def test_install_python(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': 0, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__grains__, {'os': 'Linux'}):
mock_all = MagicMock(return_value={'retcode': 0, 'stdout': 'salt',... |
'Test if it uninstall a python implementation.'
| def test_uninstall_python(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it list the installed versions of python.'
| def test_versions(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it returns or sets the currently defined default python.'
| def test_default(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it list the installable versions of python.'
| def test_list(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it run pyenv rehash to update the installed shims.'
| def test_rehash(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it execute a python command with pyenv\'s
shims from the user or the system.'
| def test_do(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test if it execute a python command with pyenv\'s
shims using a specific python version.'
| def test_do_with_python(self):
| mock_opt = MagicMock(return_value='salt stack')
mock_cmd = MagicMock(return_value=True)
mock_all = MagicMock(return_value={'retcode': True, 'stdout': 'salt', 'stderr': 'error'})
with patch.dict(pyenv.__salt__, {'cmd.has_exec': mock_cmd, 'config.option': mock_opt, 'cmd.run_all': mock_all}):
se... |
'Test - Return return the active kernel version'
| def test_active(self):
| self.assertEqual(self._kernelpkg.active(), self.KERNEL_LIST[0])
|
'Test - Return the latest available kernel version'
| def test_latest_available_no_results(self):
| mock = MagicMock(return_value='')
with patch.dict(self._kernelpkg.__salt__, {'pkg.latest_version': mock}):
with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
self.assertEqual(self._kernelpkg.latest_available(), self.KERNEL_LIST[(-1)])
|
'Test - Return the latest available kernel version'
| def test_latest_available_at_latest(self):
| mock = MagicMock(return_value=self.LATEST)
with patch.dict(self._kernelpkg.__salt__, {'pkg.latest_version': mock}):
with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[(-1)]):
self.assertEqual(self._kernelpkg.latest_available(), self.KERNEL_LIST[(-1)])
|
'Test - Return the latest available kernel version'
| def test_latest_available_with_updates(self):
| mock = MagicMock(return_value=self.LATEST)
with patch.dict(self._kernelpkg.__salt__, {'pkg.latest_version': mock}):
with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
self.assertEqual(self._kernelpkg.latest_available(), self.KERNEL_LIST[(-1)])
|
'Test - Return the latest installed kernel version'
| def test_latest_installed_with_updates(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
self.assertEqual(self._kernelpkg.latest_installed(), self.KERNEL_LIST[(-1)])
|
'Test - Return the latest installed kernel version'
| def test_latest_installed_at_latest(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[(-1)]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
self.assertEqual(self._kernelpkg.latest_installed(), self.KERNEL_LIST[(-1)])
|
'Test - Return True if a new kernel is ready to be booted'
| def test_needs_reboot_with_update(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[1]):
self.assertTrue(self._kernelpkg.needs_reboot())
|
'Test - Return True if a new kernel is ready to be booted'
| def test_needs_reboot_at_latest(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[1]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[1]):
self.assertFalse(self._kernelpkg.needs_reboot())
|
'Test - Return True if a new kernel is ready to be booted'
| def test_needs_reboot_order_inverted(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[1]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[0]):
self.assertFalse(self._kernelpkg.needs_reboot())
|
'Test - Upgrade function when no upgrade is available and reboot has been requested'
| def test_upgrade_not_needed_with_reboot(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[(-1)]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
result = self._kernelpkg.upgrade(reboot=True)
self.assertIn('upgrades', result)
self.assertEqual(result[... |
'Test - Upgrade function when no upgrade is available and no reboot has been requested'
| def test_upgrade_not_needed_without_reboot(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[(-1)]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
result = self._kernelpkg.upgrade(reboot=False)
self.assertIn('upgrades', result)
self.assertEqual(result... |
'Test - Upgrade function when an upgrade is available and reboot has been requested'
| def test_upgrade_needed_with_reboot(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
result = self._kernelpkg.upgrade(reboot=True)
self.assertIn('upgrades', result)
self.assertEqual(result['ac... |
'Test - Upgrade function when an upgrade is available and no reboot has been requested'
| def test_upgrade_needed_without_reboot(self):
| with patch.object(self._kernelpkg, 'active', return_value=self.KERNEL_LIST[0]):
with patch.object(self._kernelpkg, 'list_installed', return_value=self.KERNEL_LIST):
result = self._kernelpkg.upgrade(reboot=False)
self.assertIn('upgrades', result)
self.assertEqual(result['a... |
'Test - upgrade_available'
| def test_upgrade_available_true(self):
| with patch.object(self._kernelpkg, 'latest_available', return_value=self.KERNEL_LIST[(-1)]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[0]):
self.assertTrue(self._kernelpkg.upgrade_available())
|
'Test - upgrade_available'
| def test_upgrade_available_false(self):
| with patch.object(self._kernelpkg, 'latest_available', return_value=self.KERNEL_LIST[(-1)]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[(-1)]):
self.assertFalse(self._kernelpkg.upgrade_available())
|
'Test - upgrade_available'
| def test_upgrade_available_inverted(self):
| with patch.object(self._kernelpkg, 'latest_available', return_value=self.KERNEL_LIST[0]):
with patch.object(self._kernelpkg, 'latest_installed', return_value=self.KERNEL_LIST[(-1)]):
self.assertFalse(self._kernelpkg.upgrade_available())
|
'Test to see if mysql module properly forms the MySQL query to see if a user exists
Do it before test_user_create_when_user_exists mocks the user_exists call'
| def test_user_exists(self):
| self._test_call(mysql.user_exists, {'sql': 'SELECT User,Host FROM mysql.user WHERE User = %(user)s AND Host = %(host)s AND Password = PASSWORD(%(password)s)', 'sql_args': {'host': 'localhost', 'password': 'BLUECOW', 'user': 'mytestuser'}}, user='mytestuser', host='localh... |
'Test the creation of a MySQL user in mysql exec module'
| def test_user_create(self):
| self._test_call(mysql.user_create, {'sql': 'CREATE USER %(user)s@%(host)s IDENTIFIED BY %(password)s', 'sql_args': {'password': 'BLUECOW', 'user': 'testuser', 'host': 'localhost'}}, 'testuser', password='BLUECOW')
|
'Test changing a MySQL user password in mysql exec module'
| def test_user_chpass(self):
| connect_mock = MagicMock()
with patch.object(mysql, '_connect', connect_mock):
with patch.dict(mysql.__salt__, {'config.option': MagicMock()}):
mysql.user_chpass('testuser', password='BLUECOW')
calls = (call().cursor().execute('UPDATE mysql.user SET Password=PASSWORD(%(p... |
'Test the removal of a MySQL user in mysql exec module'
| def test_user_remove(self):
| self._test_call(mysql.user_remove, {'sql': 'DROP USER %(user)s@%(host)s', 'sql_args': {'user': 'testuser', 'host': 'localhost'}}, 'testuser')
|
'Test MySQL db check function in mysql exec module'
| def test_db_check(self):
| self._test_call(mysql.db_check, 'CHECK TABLE `test``\'" db`.`my``\'" table`', 'test`\'" db', 'my`\'" table')
|
'Test MySQL db repair function in mysql exec module'
| def test_db_repair(self):
| self._test_call(mysql.db_repair, 'REPAIR TABLE `test``\'" db`.`my``\'" table`', 'test`\'" db', 'my`\'" table')
|
'Test MySQL db optimize function in mysql exec module'
| def test_db_optimize(self):
| self._test_call(mysql.db_optimize, 'OPTIMIZE TABLE `test``\'" db`.`my``\'" table`', 'test`\'" db', 'my`\'" table')
|
'Test MySQL db remove function in mysql exec module'
| def test_db_remove(self):
| with patch.object(mysql, 'db_exists', MagicMock(return_value=True)):
self._test_call(mysql.db_remove, 'DROP DATABASE `test``\'" db`;', 'test`\'" db')
|
'Test MySQL db_tables function in mysql exec module'
| def test_db_tables(self):
| with patch.object(mysql, 'db_exists', MagicMock(return_value=True)):
self._test_call(mysql.db_tables, 'SHOW TABLES IN `test``\'" db`', 'test`\'" db')
|
'Test MySQL db_exists function in mysql exec module'
| def test_db_exists(self):
| self._test_call(mysql.db_exists, {'sql': 'SHOW DATABASES LIKE %(dbname)s;', 'sql_args': {'dbname': 'test%_`" db'}}, 'test%_`" db')
|
'Test MySQL db_create function in mysql exec module'
| def test_db_create(self):
| self._test_call(mysql.db_create, 'CREATE DATABASE IF NOT EXISTS `test``\'" db`;', 'test`\'" db')
|
'Test MySQL user_list function in mysql exec module'
| def test_user_list(self):
| self._test_call(mysql.user_list, 'SELECT User,Host FROM mysql.user')
|
'Test to see if the mysql execution module correctly forms the SQL for information on a MySQL user.'
| def test_user_info(self):
| self._test_call(mysql.user_info, {'sql': 'SELECT * FROM mysql.user WHERE User = %(user)s AND Host = %(host)s', 'sql_args': {'host': 'localhost', 'user': 'mytestuser'}}, 'mytestuser')
|
'Test to ensure the mysql user_grants function returns properly formed SQL for a basic query'
| def test_user_grants(self):
| with patch.object(mysql, 'user_exists', MagicMock(return_value=True)):
self._test_call(mysql.user_grants, {'sql': 'SHOW GRANTS FOR %(user)s@%(host)s', 'sql_args': {'host': 'localhost', 'user': 'testuser'}}, 'testuser')
|
'Test to ensure that we can find a grant that exists'
| def test_grant_exists_true(self):
| mock_grants = ["GRANT USAGE ON *.* TO 'testuser'@'%'", "GRANT SELECT, INSERT, UPDATE ON `testdb`.`testtableone` TO 'testuser'@'%'", "GRANT SELECT ON `testdb`.`testtabletwo` TO 'testuer'@'%'", "GRANT SELECT ON `testdb`.`testtablethree` TO 'testuser'@'... |
'Test to ensure that we don\'t find a grant that doesn\'t exist'
| def test_grant_exists_false(self):
| mock_grants = ["GRANT USAGE ON *.* TO 'testuser'@'%'", "GRANT SELECT, INSERT, UPDATE ON `testdb`.`testtableone` TO 'testuser'@'%'", "GRANT SELECT ON `testdb`.`testtablethree` TO 'testuser'@'%'"]
mock = MagicMock(return_value=mock_grants)
with patch.object(m... |
'Test grant_add function in mysql exec module'
| @skipIf(True, 'TODO: Mock up user_grants()')
def test_grant_add(self):
| self._test_call(mysql.grant_add, '', 'SELECT,INSERT,UPDATE', 'database.*', 'frank', 'localhost')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.