Added unit tests for new tenant and delete tenant 52/2052/1
authorkasar <pkasar@vmware.com>
Mon, 31 Jul 2017 08:25:55 +0000 (01:25 -0700)
committerkasar <pkasar@vmware.com>
Mon, 31 Jul 2017 08:26:04 +0000 (01:26 -0700)
Change-Id: I520c2d9a869e25413557b11129c9517440b5ac36
Signed-off-by: kasar <pkasar@vmware.com>
test/test_RO.py

index 10894f7..38098ff 100755 (executable)
@@ -1302,6 +1302,53 @@ class test_vimconn_get_tenant_list(test_base):
 
         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)
 
 '''
 IMPORTANT NOTE