+class test_vimconn_get_tenant_list(test_base):
+ tenant_id = None
+
+ def test_000_get_tenant_list(self):
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ # Getting tenant list
+ tenant_list = test_config["vim_conn"].get_tenant_list()
+
+ for item in tenant_list:
+ if test_config['tenant'] == item['name']:
+ self.__class__.tenant_id = item['id']
+ self.assertEqual(type(item['name']), str)
+ self.assertEqual(type(item['id']), str)
+
+ def test_010_get_tenant_list_by_id(self):
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ # Getting filter tenant list by its id
+ filter_tenant_list = test_config["vim_conn"].get_tenant_list({'id': self.__class__.tenant_id})
+
+ for item in filter_tenant_list:
+ self.assertEqual(type(item['id']), str)
+ self.assertEqual(item['id'], self.__class__.tenant_id)
+
+ def test_020_get_tenant_list_by_name(self):
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ # Getting filter tenant list by its name
+ filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': test_config['tenant']})
+
+ for item in filter_tenant_list:
+ self.assertEqual(type(item['name']), str)
+ self.assertEqual(item['name'], test_config['tenant'])
+
+ def test_030_get_tenant_list_by_name_and_id(self):
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ # Getting filter tenant list by its name and id
+ filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': test_config['tenant'],
+ 'id': self.__class__.tenant_id})
+
+ for item in filter_tenant_list:
+ self.assertEqual(type(item['name']), str)
+ self.assertEqual(type(item['id']), str)
+ self.assertEqual(item['name'], test_config['tenant'])
+ self.assertEqual(item['id'], self.__class__.tenant_id)
+
+ def test_040_get_tenant_list_negative(self):
+ non_exist_tenant_name = "Tenant_123"
+ non_exist_tenant_id = "kjhgrt456-45345kjhdfgnbdk-34dsfjdfg"
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': non_exist_tenant_name,
+ 'id': non_exist_tenant_id})
+
+ self.assertEqual(filter_tenant_list, [])
+
+class test_vimconn_new_tenant(test_base):
+ tenant_id = None
+
+ def test_000_new_tenant(self):
+ tenant_name = _get_random_string(20)
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ self.__class__.tenant_id = test_config["vim_conn"].new_tenant(tenant_name)
+ time.sleep(15)
+
+ self.assertEqual(type(self.__class__.tenant_id), str)
+
+ def test_010_new_tenant_negative(self):
+ Invalid_tenant_name = 10121
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ with self.assertRaises(Exception) as context:
+ test_config["vim_conn"].new_tenant(Invalid_tenant_name)
+
+ self.assertEqual((context.exception).http_code, 400)
+
+ def test_020_delete_tenant(self):
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ tenant_id = test_config["vim_conn"].delete_tenant(self.__class__.tenant_id)
+ self.assertEqual(type(tenant_id), str)
+
+ def test_030_delete_tenant_negative(self):
+ Non_exist_tenant_name = 'Test_30_tenant'
+ self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+ self.__class__.test_index,
+ inspect.currentframe().f_code.co_name)
+ self.__class__.test_index += 1
+
+ with self.assertRaises(Exception) as context:
+ test_config["vim_conn"].delete_tenant(Non_exist_tenant_name)
+
+ self.assertEqual((context.exception).http_code, 404)
+
+