def setUp(self): self.client_real = Client('150.165.85.176', 'administrator', '1r0n1c@LSD') self.flavor_list_real = self.client_real.flavor_list() self.oneviewrequest = OneViewRequest('150.165.85.176', 'administrator', '1r0n1c@LSD') self.client_fake = Client('address', 'username', 'password')
class TestOneViewFlavorListTable(unittest.TestCase): def setUp(self): self.client_real = Client('150.165.85.176', 'administrator', '1r0n1c@LSD') self.flavor_list_real = self.client_real.flavor_list() self.oneviewrequest = OneViewRequest('150.165.85.176', 'administrator', '1r0n1c@LSD') self.client_fake = Client('address', 'username', 'password') def test_list_not_empty_using_real_oneview_with_server_hardwares_and_server_profiles(self): server_hardware_list = self.oneviewrequest.server_hardware_list() server_profile_list = self.oneviewrequest.server_profile_list() self.assertTrue([] != server_hardware_list) self.assertTrue([] != server_profile_list) self.assertTrue([] != self.flavor_list_real) def test_connection_error_no_valid_auth(self): with self.assertRaises(exceptions.ConnectionError): flavor_list_error = self.client_fake.flavor_list() @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile_template(self, mock_sh, mock_sp): server_hardware_list_empty = [] server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sh.return_value = server_hardware_list_empty mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client_real.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile(self, mock_sp): server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client_real.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_hardware(self, mock_sh): server_hardware_list_empty = [] mock_sh.return_value = server_hardware_list_empty self.assertEquals(list(self.client_real.flavor_list()), [])
class TestOneViewClient(unittest.TestCase): def setUp(self): self.client = Client('address', 'username', 'password') @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile_template(self, mock_sh, mock_sp): server_hardware_list_empty = [] server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sh.return_value = server_hardware_list_empty mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) @mock.patch.object(OneViewRequest, 'get_volumes', autospec=True) def test_flavor_list_reflects_server_profile_template_and_server_hardware(self, mock_vo, mock_sh, mock_sp): server_hardware_list_not_empty = [{'name': 'sh1', 'serverHardwareTypeUri': 'shtUri1', 'enclosureGroupUri': 'egUri1', 'memoryMb': 16384, 'processorCoreCount': 3, 'processorCount': 2, }] server_profile_list_not_empty = [{'name': 'sp1', 'serverHardwareTypeUri': 'shtUri1', 'enclosureGroupUri': 'egUri1', 'sanStorage': {'volumeAttachments': [{'volumeUri': 'volUri1'}]}, 'uri': 'spUri1'}] expected_flavor = {} expected_flavor['ram_mb'] = 16384 expected_flavor['cpus'] = 6 expected_flavor['disk'] = 2 extra_spec = {} extra_spec['cpu_arch'] = 'x86_64' extra_spec['oneview:server_profile_template_uri'] = 'spUri1' extra_spec['capabilities:server_hardware_type_uri'] = 'shtUri1' extra_spec['capabilities:enclosure_group_uri'] = 'egUri1' expected_flavor['extra_specs'] = extra_spec expected_flavor_list = [Flavor(len(list(self.client.flavor_list())) + 1, info=expected_flavor)] mock_sh.return_value = server_hardware_list_not_empty mock_sp.return_value = server_profile_list_not_empty mock_vo.return_value = {'provisionedCapacity': 1073741824 * 2} # self.assertEquals(sorted(list(self.client.flavor_list())), sorted(expected_flavor_list)) def test_server_hardware_and_server_profile_not_empty(self): return_value = self.client.flavor_list() print(return_value) self.assertFalse([] == return_value)
class TestOneViewFlavorListTable(unittest.TestCase): def setUp(self): self.client_real = Client('150.165.85.176', 'administrator', '1r0n1c@LSD') self.flavor_list_real = self.client_real.flavor_list() self.oneviewrequest = OneViewRequest('150.165.85.176', 'administrator', '1r0n1c@LSD') self.client_fake = Client('address', 'username', 'password') def test_list_not_empty_using_real_oneview_with_server_hardwares_and_server_profiles( self): server_hardware_list = self.oneviewrequest.server_hardware_list() server_profile_list = self.oneviewrequest.server_profile_list() self.assertTrue([] != server_hardware_list) self.assertTrue([] != server_profile_list) self.assertTrue([] != self.flavor_list_real) def test_connection_error_no_valid_auth(self): with self.assertRaises(exceptions.ConnectionError): flavor_list_error = self.client_fake.flavor_list() @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile_template( self, mock_sh, mock_sp): server_hardware_list_empty = [] server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sh.return_value = server_hardware_list_empty mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client_real.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile( self, mock_sp): server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client_real.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_hardware( self, mock_sh): server_hardware_list_empty = [] mock_sh.return_value = server_hardware_list_empty self.assertEquals(list(self.client_real.flavor_list()), [])
def setUp(self): self.client = Client('address', 'username', 'password')
class TestOneViewClient(unittest.TestCase): def setUp(self): self.client = Client('address', 'username', 'password') @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) def test_flavor_list_empty_when_oneview_has_no_server_profile_template( self, mock_sh, mock_sp): server_hardware_list_empty = [] server_profile_list_empty = [] server_profile_template_list_empty = [] mock_sh.return_value = server_hardware_list_empty mock_sp.return_value = server_profile_list_empty self.assertEquals(list(self.client.flavor_list()), []) @mock.patch.object(OneViewRequest, 'server_profile_list', autospec=True) @mock.patch.object(OneViewRequest, 'server_hardware_list', autospec=True) @mock.patch.object(OneViewRequest, 'get_volumes', autospec=True) def test_flavor_list_reflects_server_profile_template_and_server_hardware( self, mock_vo, mock_sh, mock_sp): server_hardware_list_not_empty = [{ 'name': 'sh1', 'serverHardwareTypeUri': 'shtUri1', 'enclosureGroupUri': 'egUri1', 'memoryMb': 16384, 'processorCoreCount': 3, 'processorCount': 2, }] server_profile_list_not_empty = [{ 'name': 'sp1', 'serverHardwareTypeUri': 'shtUri1', 'enclosureGroupUri': 'egUri1', 'sanStorage': { 'volumeAttachments': [{ 'volumeUri': 'volUri1' }] }, 'uri': 'spUri1' }] expected_flavor = {} expected_flavor['ram_mb'] = 16384 expected_flavor['cpus'] = 6 expected_flavor['disk'] = 2 extra_spec = {} extra_spec['cpu_arch'] = 'x86_64' extra_spec['oneview:server_profile_template_uri'] = 'spUri1' extra_spec['capabilities:server_hardware_type_uri'] = 'shtUri1' extra_spec['capabilities:enclosure_group_uri'] = 'egUri1' expected_flavor['extra_specs'] = extra_spec expected_flavor_list = [ Flavor(len(list(self.client.flavor_list())) + 1, info=expected_flavor) ] mock_sh.return_value = server_hardware_list_not_empty mock_sp.return_value = server_profile_list_not_empty mock_vo.return_value = {'provisionedCapacity': 1073741824 * 2} # self.assertEquals(sorted(list(self.client.flavor_list())), sorted(expected_flavor_list)) def test_server_hardware_and_server_profile_not_empty(self): return_value = self.client.flavor_list() print(return_value) self.assertFalse([] == return_value)