From: kasar Date: Mon, 31 Jul 2017 08:25:55 +0000 (-0700) Subject: Added unit tests for new tenant and delete tenant X-Git-Tag: v3.0.0~17^2~18 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F2052%2F1;p=osm%2FRO.git Added unit tests for new tenant and delete tenant Change-Id: I520c2d9a869e25413557b11129c9517440b5ac36 Signed-off-by: kasar --- diff --git a/test/test_RO.py b/test/test_RO.py index 10894f7a..38098ff0 100755 --- a/test/test_RO.py +++ b/test/test_RO.py @@ -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