desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Mock of create_vpnservice method'
| @staticmethod
def create_vpnservice(subnet, router, name, admin_state_up):
| return (subnet, router, name, admin_state_up)
|
'Mock of update_vpnservice method'
| @staticmethod
def update_vpnservice(vpnservice, desc):
| return (vpnservice, desc)
|
'Mock of delete_vpnservice method'
| @staticmethod
def delete_vpnservice(vpnservice):
| return vpnservice
|
'Mock of list_ipsec_site_connections method'
| @staticmethod
def list_ipsec_site_connections():
| return True
|
'Mock of show_ipsec_site_connection method'
| @staticmethod
def show_ipsec_site_connection(ipsec_site_connection):
| return ipsec_site_connection
|
'Mock of create_ipsec_site_connection method'
| @staticmethod
def create_ipsec_site_connection(name, ipsecpolicy, ikepolicy, vpnservice, peer_cidrs, peer_address, peer_id, psk, admin_state_up, **kwargs):
| return (name, ipsecpolicy, ikepolicy, vpnservice, peer_cidrs, peer_address, peer_id, psk, admin_state_up, kwargs)
|
'Mock of delete_vpnservice method'
| @staticmethod
def delete_ipsec_site_connection(ipsec_site_connection):
| return ipsec_site_connection
|
'Mock of list_ikepolicies method'
| @staticmethod
def list_ikepolicies():
| return True
|
'Mock of show_ikepolicy method'
| @staticmethod
def show_ikepolicy(ikepolicy):
| return ikepolicy
|
'Mock of create_ikepolicy method'
| @staticmethod
def create_ikepolicy(name, **kwargs):
| return (name, kwargs)
|
'Mock of delete_ikepolicy method'
| @staticmethod
def delete_ikepolicy(ikepolicy):
| return ikepolicy
|
'Mock of list_ipsecpolicies method'
| @staticmethod
def list_ipsecpolicies():
| return True
|
'Mock of show_ipsecpolicy method'
| @staticmethod
def show_ipsecpolicy(ipsecpolicy):
| return ipsecpolicy
|
'Mock of create_ikepolicy method'
| @staticmethod
def create_ipsecpolicy(name, **kwargs):
| return (name, kwargs)
|
'Mock of delete_ipsecpolicy method'
| @staticmethod
def delete_ipsecpolicy(ipsecpolicy):
| return ipsecpolicy
|
'Test if it fetches tenant info in server\'s context for
following quota operation'
| def test_get_quotas_tenant(self):
| self.assertTrue(neutron.get_quotas_tenant(profile='openstack1'))
|
'Test if it fetches all tenants quotas'
| def test_list_quotas(self):
| self.assertTrue(neutron.list_quotas(profile='openstack1'))
|
'Test if it fetches information of a certain tenant\'s quotas'
| def test_show_quota(self):
| self.assertTrue(neutron.show_quota('Salt', profile='openstack1'))
|
'Test if it update a tenant\'s quota'
| def test_update_quota(self):
| self.assertTrue(neutron.update_quota('Salt', subnet='40', router='50', network='10', floatingip='30', port='30', security_group='10', security_group_rule='SS'))
|
'Test if it delete the specified tenant\'s quota value'
| def test_delete_quota(self):
| self.assertTrue(neutron.delete_quota('Salt', profile='openstack1'))
|
'Test if it fetches a list of all extensions on server side'
| def test_list_extensions(self):
| self.assertTrue(neutron.list_extensions(profile='openstack1'))
|
'Test if it fetches a list of all networks for a tenant'
| def test_list_ports(self):
| self.assertTrue(neutron.list_ports(profile='openstack1'))
|
'Test if it fetches information of a certain port'
| def test_show_port(self):
| self.assertTrue(neutron.show_port('1080', profile='openstack1'))
|
'Test if it creates a new port'
| def test_create_port(self):
| self.assertTrue(neutron.create_port('Salt', 'SALTSTACK', device_id='800', admin_state_up=True, profile='openstack1'))
|
'Test if it updates a port'
| def test_update_port(self):
| self.assertTrue(neutron.update_port('800', 'SALTSTACK', admin_state_up=True, profile='openstack1'))
|
'Test if it deletes the specified port'
| def test_delete_port(self):
| self.assertTrue(neutron.delete_port('1080', profile='openstack1'))
|
'Test if it fetches a list of all networks for a tenant'
| def test_list_networks(self):
| self.assertTrue(neutron.list_networks(profile='openstack1'))
|
'Test if it fetches information of a certain network'
| def test_show_network(self):
| self.assertTrue(neutron.show_network('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new network'
| def test_create_network(self):
| self.assertTrue(neutron.create_network('SALT', profile='openstack1'))
|
'Test if it updates a network'
| def test_update_network(self):
| self.assertTrue(neutron.update_network('SALT', 'SLATSTACK', profile='openstack1'))
|
'Test if it deletes the specified network'
| def test_delete_network(self):
| self.assertTrue(neutron.delete_network('SALTSTACK', profile='openstack1'))
|
'Test if it fetches a list of all networks for a tenant'
| def test_list_subnets(self):
| self.assertTrue(neutron.list_subnets(profile='openstack1'))
|
'Test if it fetches information of a certain subnet'
| def test_show_subnet(self):
| self.assertTrue(neutron.show_subnet('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new subnet'
| def test_create_subnet(self):
| self.assertTrue(neutron.create_subnet('192.168.1.0', '192.168.1.0/24', name='Salt', ip_version=4, profile='openstack1'))
|
'Test if it updates a subnet'
| def test_update_subnet(self):
| self.assertTrue(neutron.update_subnet('255.255.255.0', name='Salt', profile='openstack1'))
|
'Test if it deletes the specified subnet'
| def test_delete_subnet(self):
| self.assertTrue(neutron.delete_subnet('255.255.255.0', profile='openstack1'))
|
'Test if it fetches a list of all routers for a tenant'
| def test_list_routers(self):
| self.assertTrue(neutron.list_routers(profile='openstack1'))
|
'Test if it fetches information of a certain router'
| def test_show_router(self):
| self.assertTrue(neutron.show_router('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new router'
| def test_create_router(self):
| self.assertTrue(neutron.create_router('SALT', '192.168.1.0', admin_state_up=True, profile='openstack1'))
|
'Test if it updates a router'
| def test_update_router(self):
| self.assertTrue(neutron.update_router('255.255.255.0', name='Salt', profile='openstack1'))
|
'Test if it delete the specified router'
| def test_delete_router(self):
| self.assertTrue(neutron.delete_router('SALTSTACK', profile='openstack1'))
|
'Test if it adds an internal network interface to the specified router'
| def test_add_interface_router(self):
| self.assertTrue(neutron.add_interface_router('Salt', '255.255.255.0', profile='openstack1'))
|
'Test if it removes an internal network interface from the specified
router'
| def test_remove_interface_router(self):
| self.assertTrue(neutron.remove_interface_router('Salt', '255.255.255.0', profile='openstack1'))
|
'Test if it adds an external network gateway to the specified router'
| def test_add_gateway_router(self):
| self.assertTrue(neutron.add_gateway_router('Salt', 'SALTSTACK', profile='openstack1'))
|
'Test if it removes an external network gateway from the specified router'
| def test_remove_gateway_router(self):
| self.assertTrue(neutron.remove_gateway_router('SALTSTACK', profile='openstack1'))
|
'Test if it fetch a list of all floatingIPs for a tenant'
| def test_list_floatingips(self):
| self.assertTrue(neutron.list_floatingips(profile='openstack1'))
|
'Test if it fetches information of a certain floatingIP'
| def test_show_floatingip(self):
| self.assertTrue(neutron.show_floatingip('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new floatingIP'
| def test_create_floatingip(self):
| self.assertTrue(neutron.create_floatingip('SALTSTACK', port='800', profile='openstack1'))
|
'Test if it updates a floatingIP'
| def test_update_floatingip(self):
| self.assertTrue(neutron.update_floatingip('SALTSTACK', port='800', profile='openstack1'))
|
'Test if it deletes the specified floating IP'
| def test_delete_floatingip(self):
| self.assertTrue(neutron.delete_floatingip('SALTSTACK', profile='openstack1'))
|
'Test if it fetches a list of all security groups for a tenant'
| def test_list_security_groups(self):
| self.assertTrue(neutron.list_security_groups(profile='openstack1'))
|
'Test if it fetches information of a certain security group'
| def test_show_security_group(self):
| self.assertTrue(neutron.show_security_group('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new security group'
| def test_create_security_group(self):
| self.assertTrue(neutron.create_security_group('SALTSTACK', 'Security group', profile='openstack1'))
|
'Test if it updates a security group'
| def test_update_security_group(self):
| self.assertTrue(neutron.update_security_group('SALT', 'SALTSTACK', 'Security group', profile='openstack1'))
|
'Test if it deletes the specified security group'
| def test_delete_security_group(self):
| self.assertTrue(neutron.delete_security_group('SALT', profile='openstack1'))
|
'Test if it fetches a list of all security group rules for a tenant'
| def test_list_security_group_rules(self):
| self.assertTrue(neutron.list_security_group_rules(profile='openstack1'))
|
'Test if it fetches information of a certain security group rule'
| def test_show_security_group_rule(self):
| self.assertTrue(neutron.show_security_group_rule('SALTSTACK', profile='openstack1'))
|
'Test if it creates a new security group rule'
| def test_create_security_group_rule(self):
| self.assertTrue(neutron.create_security_group_rule('SALTSTACK', profile='openstack1'))
|
'Test if it deletes the specified security group rule'
| def test_delete_security_group_rule(self):
| self.assertTrue(neutron.delete_security_group_rule('SALTSTACK', profile='openstack1'))
|
'Test if it fetches a list of all configured VPN services for a tenant'
| def test_list_vpnservices(self):
| self.assertTrue(neutron.list_vpnservices(True, profile='openstack1'))
|
'Test if it fetches information of a specific VPN service'
| def test_show_vpnservice(self):
| self.assertTrue(neutron.show_vpnservice('SALT', profile='openstack1'))
|
'Test if it creates a new VPN service'
| def test_create_vpnservice(self):
| self.assertTrue(neutron.create_vpnservice('255.255.255.0', 'SALT', 'SALTSTACK', True, profile='openstack1'))
|
'Test if it updates a VPN service'
| def test_update_vpnservice(self):
| self.assertTrue(neutron.update_vpnservice('SALT', 'VPN Service1', profile='openstack1'))
|
'Test if it deletes the specified VPN service'
| def test_delete_vpnservice(self):
| self.assertTrue(neutron.delete_vpnservice('SALT VPN Service1', profile='openstack1'))
|
'Test if it fetches all configured IPsec Site Connections for a tenant'
| def test_list_ipsec_site(self):
| self.assertTrue(neutron.list_ipsec_site_connections(profile='openstack1'))
|
'Test if it fetches information of a specific IPsecSiteConnection'
| def test_show_ipsec_site_connection(self):
| self.assertTrue(neutron.show_ipsec_site_connection('SALT', profile='openstack1'))
|
'Test if it creates a new IPsecSiteConnection'
| def test_create_ipsec_site(self):
| self.assertTrue(neutron.create_ipsec_site_connection('SALTSTACK', 'A', 'B', 'C', '192.168.1.0/24', '192.168.1.11', '192.168.1.10', 'secret', profile='openstack1'))
|
'Test if it deletes the specified IPsecSiteConnection'
| def test_delete_ipsec_site(self):
| self.assertTrue(neutron.delete_ipsec_site_connection('SALT VPN Service1', profile='openstack1'))
|
'Test if it fetches a list of all configured IKEPolicies for a tenant'
| def test_list_ikepolicies(self):
| self.assertTrue(neutron.list_ikepolicies(profile='openstack1'))
|
'Test if it fetches information of a specific IKEPolicy'
| def test_show_ikepolicy(self):
| self.assertTrue(neutron.show_ikepolicy('SALT', profile='openstack1'))
|
'Test if it creates a new IKEPolicy'
| def test_create_ikepolicy(self):
| self.assertTrue(neutron.create_ikepolicy('SALTSTACK', profile='openstack1'))
|
'Test if it deletes the specified IKEPolicy'
| def test_delete_ikepolicy(self):
| self.assertTrue(neutron.delete_ikepolicy('SALT', profile='openstack1'))
|
'Test if it fetches a list of all configured IPsecPolicies for a tenant'
| def test_list_ipsecpolicies(self):
| self.assertTrue(neutron.list_ipsecpolicies(profile='openstack1'))
|
'Test if it fetches information of a specific IPsecPolicy'
| def test_show_ipsecpolicy(self):
| self.assertTrue(neutron.show_ipsecpolicy('SALT', profile='openstack1'))
|
'Test if it creates a new IPsecPolicy'
| def test_create_ipsecpolicy(self):
| self.assertTrue(neutron.create_ipsecpolicy('SALTSTACK', profile='openstack1'))
|
'Test if it deletes the specified IPsecPolicy'
| def test_delete_ipsecpolicy(self):
| self.assertTrue(neutron.delete_ipsecpolicy('SALT', profile='openstack1'))
|
'Test to display the Subversion information from the checkout.'
| def test_info(self):
| mock = MagicMock(side_effect=[{'retcode': 0, 'stdout': True}, {'retcode': 0, 'stdout': 'A\n\nB'}, {'retcode': 0, 'stdout': 'A\n\nB'}])
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.info('cwd', fmt='xml'))
self.assertListEqual(svn.info('cwd', fmt='list'), [[], []])
self.assertListEqual(svn.info('cwd', fmt='dict'), [{}, {}])
|
'Test to download a working copy of the remote Subversion repository
directory or file'
| def test_checkout(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.checkout('cwd', 'remote'))
|
'Test to switch a working copy of a remote Subversion repository
directory'
| def test_switch(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.switch('cwd', 'remote'))
|
'Test to update the current directory, files, or directories from
the remote Subversion repository'
| def test_update(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.update('cwd'))
|
'Test to return the diff of the current directory, files, or
directories from the remote Subversion repository'
| def test_diff(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.diff('cwd'))
|
'Test to commit the current directory, files, or directories to
the remote Subversion repository'
| def test_commit(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.commit('cwd'))
|
'Test to add files to be tracked by the Subversion working-copy
checkout'
| def test_add(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.add('cwd', False))
|
'Test to remove files and directories from the Subversion repository'
| def test_remove(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.remove('cwd', False))
|
'Test to display the status of the current directory, files, or
directories in the Subversion repository'
| def test_status(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.status('cwd'))
|
'Test to create an unversioned copy of a tree.'
| def test_export(self):
| mock = MagicMock(return_value={'retcode': 0, 'stdout': True})
with patch.dict(svn.__salt__, {'cmd.run_all': mock}):
self.assertTrue(svn.export('cwd', 'remote'))
|
'Test for listing installed packages.'
| def test_list_pkgs(self):
| def _add_data(data, key, value):
data[key] = value
pkg_info_out = ['png-1.6.23', 'vim-7.4.1467p1-gtk2', 'ruby-2.3.1p1']
run_stdout_mock = MagicMock(return_value='\n'.join(pkg_info_out))
patches = {'cmd.run_stdout': run_stdout_mock, 'pkg_resource.add_pkg': _add_data, 'pkg_resource.sort_pkglist': MagicMock(), 'pkg_resource.stringify': MagicMock()}
with patch.dict(openbsdpkg.__salt__, patches):
pkgs = openbsdpkg.list_pkgs()
self.assertDictEqual(pkgs, {'png': '1.6.23', 'vim--gtk2': '7.4.1467p1', 'ruby': '2.3.1p1'})
run_stdout_mock.assert_called_once_with('pkg_info -q -a', output_loglevel='trace')
|
'Test package install behavior for the following conditions:
- only base package name is given (\'png\')
- a flavor is specified (\'vim--gtk2\')
- a branch is specified (\'ruby%2.3\')'
| def test_install_pkgs(self):
| class ListPackages(object, ):
def __init__(self):
self._iteration = 0
def __call__(self):
pkg_lists = [{'vim': '7.4.1467p1-gtk2'}, {'png': '1.6.23', 'vim': '7.4.1467p1-gtk2', 'ruby': '2.3.1p1'}]
pkgs = pkg_lists[self._iteration]
self._iteration += 1
return pkgs
parsed_targets = ({'vim--gtk2': None, 'png': None, 'ruby%2.3': None}, 'repository')
cmd_out = {'retcode': 0, 'stdout': 'quirks-2.241 signed on 2016-07-26T16:56:10Z', 'stderr': ''}
run_all_mock = MagicMock(return_value=cmd_out)
patches = {'cmd.run_all': run_all_mock, 'pkg_resource.parse_targets': MagicMock(return_value=parsed_targets), 'pkg_resource.stringify': MagicMock(), 'pkg_resource.sort_pkglist': MagicMock()}
with patch.dict(openbsdpkg.__salt__, patches):
with patch('salt.modules.openbsdpkg.list_pkgs', ListPackages()):
added = openbsdpkg.install()
expected = {'png': {'new': '1.6.23', 'old': ''}, 'ruby': {'new': '2.3.1p1', 'old': ''}}
self.assertDictEqual(added, expected)
expected_calls = [call('pkg_add -x -I png--%', output_loglevel='trace', python_shell=False), call('pkg_add -x -I ruby--%2.3', output_loglevel='trace', python_shell=False), call('pkg_add -x -I vim--gtk2%', output_loglevel='trace', python_shell=False)]
run_all_mock.assert_has_calls(expected_calls, any_order=True)
self.assertEqual(run_all_mock.call_count, 3)
|
'Test for List services belonging to this account'
| def test_list_services(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_services(), 'A')
|
'Test for List incidents belonging to this account'
| def test_list_incidents(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_incidents(), 'A')
|
'Test for List users belonging to this account'
| def test_list_users(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_users(), 'A')
|
'Test for List schedules belonging to this account'
| def test_list_schedules(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_schedules(), 'A')
|
'Test for List maintenance windows belonging to this account'
| def test_list_windows(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_windows(), 'A')
|
'Test for List escalation policies belonging to this account'
| def test_list_policies(self):
| with patch.object(salt.utils.pagerduty, 'list_items', return_value='A'):
self.assertEqual(pagerduty.list_policies(), 'A')
|
'Test for Create an event in PagerDuty. Designed for use in states.'
| def test_create_event(self):
| with patch.object(json, 'loads', return_value=['A']):
with patch.object(salt.utils.pagerduty, 'query', return_value='A'):
self.assertListEqual(pagerduty.create_event(), ['A'])
|
'Test if it get a value from etcd, by direct path'
| def test_get(self):
| with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}):
self.instance.get.return_value = 'stack'
self.assertEqual(etcd_mod.get_('salt'), 'stack')
self.instance.get.assert_called_with('salt', recurse=False)
self.instance.tree.return_value = {}
self.assertEqual(etcd_mod.get_('salt', recurse=True), {})
self.instance.tree.assert_called_with('salt')
self.instance.get.side_effect = Exception
self.assertRaises(Exception, etcd_mod.get_, 'err')
|
'Test if it set a key in etcd, by direct path'
| def test_set(self):
| with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}):
self.instance.set.return_value = 'stack'
self.assertEqual(etcd_mod.set_('salt', 'stack'), 'stack')
self.instance.set.assert_called_with('salt', 'stack', directory=False, ttl=None)
self.instance.set.return_value = True
self.assertEqual(etcd_mod.set_('salt', '', directory=True), True)
self.instance.set.assert_called_with('salt', '', directory=True, ttl=None)
self.assertEqual(etcd_mod.set_('salt', '', directory=True, ttl=5), True)
self.instance.set.assert_called_with('salt', '', directory=True, ttl=5)
self.assertEqual(etcd_mod.set_('salt', '', None, 10, True), True)
self.instance.set.assert_called_with('salt', '', directory=True, ttl=10)
self.instance.set.side_effect = Exception
self.assertRaises(Exception, etcd_mod.set_, 'err', 'stack')
|
'Test if can set multiple keys in etcd'
| def test_update(self):
| with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}):
args = {'x': {'y': {'a': '1', 'b': '2'}}, 'z': '4', 'd': {}}
result = {'/some/path/x/y/a': '1', '/some/path/x/y/b': '2', '/some/path/z': '4', '/some/path/d': {}}
self.instance.update.return_value = result
self.assertDictEqual(etcd_mod.update(args, path='/some/path'), result)
self.instance.update.assert_called_with(args, '/some/path')
self.assertDictEqual(etcd_mod.update(args), result)
self.instance.update.assert_called_with(args, '')
|
'Test if it return all keys and dirs inside a specific path'
| def test_ls(self):
| with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}):
self.instance.ls.return_value = {'/some-dir': {}}
self.assertDictEqual(etcd_mod.ls_('/some-dir'), {'/some-dir': {}})
self.instance.ls.assert_called_with('/some-dir')
self.instance.ls.return_value = {'/': {}}
self.assertDictEqual(etcd_mod.ls_(), {'/': {}})
self.instance.ls.assert_called_with('/')
self.instance.ls.side_effect = Exception
self.assertRaises(Exception, etcd_mod.ls_, 'err')
|
'Test if it delete a key from etcd'
| def test_rm(self):
| with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}):
self.instance.rm.return_value = False
self.assertFalse(etcd_mod.rm_('dir'))
self.instance.rm.assert_called_with('dir', recurse=False)
self.instance.rm.return_value = True
self.assertTrue(etcd_mod.rm_('dir', recurse=True))
self.instance.rm.assert_called_with('dir', recurse=True)
self.instance.rm.side_effect = Exception
self.assertRaises(Exception, etcd_mod.rm_, 'err')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.