Best Python code snippet using tempest_python
test_base_test.py
Source:test_base_test.py
...28 config.CONF.service_available.neutron = True29 @mock.patch.object(test.BaseTestCase, 'get_client_manager')30 @mock.patch.object(test.BaseTestCase, '_get_credentials_provider')31 @mock.patch.object(fixed_network, 'get_tenant_network')32 def test_get_tenant_network(self, mock_gtn, mock_gprov, mock_gcm):33 net_client = mock.Mock()34 mock_prov = mock.Mock()35 mock_gcm.return_value.compute_networks_client = net_client36 mock_gprov.return_value = mock_prov37 test.BaseTestCase.get_tenant_network()38 mock_gcm.assert_called_once_with(credential_type='primary')39 mock_gprov.assert_called_once_with()40 mock_gtn.assert_called_once_with(mock_prov, net_client,41 self.fixed_network_name)42 @mock.patch.object(test.BaseTestCase, 'get_client_manager')43 @mock.patch.object(test.BaseTestCase, '_get_credentials_provider')44 @mock.patch.object(fixed_network, 'get_tenant_network')45 @mock.patch.object(test.BaseTestCase, 'get_identity_version')46 @mock.patch.object(credentials, 'is_admin_available')47 @mock.patch.object(clients, 'Manager')48 def test_get_tenant_network_with_nova_net(self, mock_man, mock_iaa,49 mock_giv, mock_gtn, mock_gcp,50 mock_gcm):51 config.CONF.service_available.neutron = False52 mock_prov = mock.Mock()53 mock_admin_man = mock.Mock()54 mock_iaa.return_value = True55 mock_gcp.return_value = mock_prov56 mock_man.return_value = mock_admin_man57 test.BaseTestCase.get_tenant_network()58 mock_man.assert_called_once_with(59 mock_prov.get_admin_creds.return_value.credentials)60 mock_iaa.assert_called_once_with(61 identity_version=mock_giv.return_value)62 mock_gcp.assert_called_once_with()63 mock_gtn.assert_called_once_with(64 mock_prov, mock_admin_man.compute_networks_client,65 self.fixed_network_name)66 @mock.patch.object(test.BaseTestCase, 'get_client_manager')67 @mock.patch.object(test.BaseTestCase, '_get_credentials_provider')68 @mock.patch.object(fixed_network, 'get_tenant_network')69 def test_get_tenant_network_with_alt_creds(self, mock_gtn, mock_gprov,70 mock_gcm):71 net_client = mock.Mock()72 mock_prov = mock.Mock()73 mock_gcm.return_value.compute_networks_client = net_client74 mock_gprov.return_value = mock_prov75 test.BaseTestCase.get_tenant_network(credentials_type='alt')76 mock_gcm.assert_called_once_with(credential_type='alt')77 mock_gprov.assert_called_once_with()78 mock_gtn.assert_called_once_with(mock_prov, net_client,79 self.fixed_network_name)80 @mock.patch.object(test.BaseTestCase, 'get_client_manager')81 @mock.patch.object(test.BaseTestCase, '_get_credentials_provider')82 @mock.patch.object(fixed_network, 'get_tenant_network')83 def test_get_tenant_network_with_role_creds(self, mock_gtn, mock_gprov,84 mock_gcm):85 net_client = mock.Mock()86 mock_prov = mock.Mock()87 mock_gcm.return_value.compute_networks_client = net_client88 mock_gprov.return_value = mock_prov89 creds = ['foo_type', 'role1']90 test.BaseTestCase.get_tenant_network(credentials_type=creds)91 mock_gcm.assert_called_once_with(roles=['role1'])92 mock_gprov.assert_called_once_with()93 mock_gtn.assert_called_once_with(mock_prov, net_client,...
test_server_actions.py
Source:test_server_actions.py
...15from cinnamon_role import test16@test.for_each_role_set17class ServerActionsTestJSON(test_server_actions.ServerActionsTestJSON):18 @classmethod19 def get_tenant_network(cls, credentials_type='primary'):20 return super(ServerActionsTestJSON, cls).get_tenant_network(...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!