Merges branch sol006 into master, allowing NBI to use, parse and validate SOL006...
[osm/NBI.git] / osm_nbi / tests / test_admin_topics.py
index d8a4e63..2c8154e 100755 (executable)
@@ -54,6 +54,7 @@ class Test_ProjectTopicAuth(TestCase):
         self.topic = ProjectTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": self.test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
         self.topic = ProjectTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": self.test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
+        self.topic.check_quota = Mock(return_value=None)  # skip quota
 
     def test_new_project(self):
         with self.subTest(i=1):
 
     def test_new_project(self):
         with self.subTest(i=1):
@@ -215,6 +216,7 @@ class Test_RoleTopicAuth(TestCase):
         self.topic = RoleTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
         self.topic = RoleTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
+        self.topic.check_quota = Mock(return_value=None)  # skip quota
 
     def test_new_role(self):
         with self.subTest(i=1):
 
     def test_new_role(self):
         with self.subTest(i=1):
@@ -375,6 +377,7 @@ class Test_UserTopicAuth(TestCase):
         self.topic = UserTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
         self.topic = UserTopicAuth(self.db, self.fs, self.msg, self.auth)
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
+        self.topic.check_quota = Mock(return_value=None)  # skip quota
 
     def test_new_user(self):
         uid1 = str(uuid4())
 
     def test_new_user(self):
         uid1 = str(uuid4())
@@ -478,6 +481,7 @@ class Test_UserTopicAuth(TestCase):
             new_name = "other-user-name"
             new_prms = [{}]
             self.auth.get_role_list.side_effect = [[user], []]
             new_name = "other-user-name"
             new_prms = [{}]
             self.auth.get_role_list.side_effect = [[user], []]
+            self.auth.get_user_list.side_effect = [[user]]
             with self.assertRaises(EngineException, msg="Accepted wrong project-role mappings") as e:
                 self.topic.edit(self.fake_session, uid, {"username": new_name, "project_role_mappings": new_prms})
             self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
             with self.assertRaises(EngineException, msg="Accepted wrong project-role mappings") as e:
                 self.topic.edit(self.fake_session, uid, {"username": new_name, "project_role_mappings": new_prms})
             self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
@@ -598,6 +602,7 @@ class Test_CommonVimWimSdn(TestCase):
         self.topic.schema_edit = validation.wim_account_edit_schema
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
         self.topic.schema_edit = validation.wim_account_edit_schema
         self.fake_session = {"username": test_name, "project_id": (test_pid,), "method": None,
                              "admin": True, "force": False, "public": False, "allow_show_user_project_role": True}
+        self.topic.check_quota = Mock(return_value=None)  # skip quota
 
     def test_new_cvws(self):
         test_url = "http://0.0.0.0:0"
 
     def test_new_cvws(self):
         test_url = "http://0.0.0.0:0"
@@ -694,6 +699,7 @@ class Test_CommonVimWimSdn(TestCase):
             self.assertEqual(operation["detailed-status"], "", "Wrong operation detailed status info")
             self.assertIsNone(operation["operationParams"], "Wrong operation parameters")
         with self.subTest(i=2):
             self.assertEqual(operation["detailed-status"], "", "Wrong operation detailed status info")
             self.assertIsNone(operation["operationParams"], "Wrong operation parameters")
         with self.subTest(i=2):
+            self.db.get_one.side_effect = [cvws]
             with self.assertRaises(EngineException, msg="Accepted wrong property") as e:
                 self.topic.edit(self.fake_session, str(uuid4()), {"name": "new-name", "extra_prop": "anything"})
             self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
             with self.assertRaises(EngineException, msg="Accepted wrong property") as e:
                 self.topic.edit(self.fake_session, str(uuid4()), {"name": "new-name", "extra_prop": "anything"})
             self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
@@ -730,8 +736,8 @@ class Test_CommonVimWimSdn(TestCase):
             self.assertEqual(self.db.set_one.call_args[0][1]["_id"], cid, "Wrong CIM identifier")
             self.assertEqual(self.db.set_one.call_args[1]["update_dict"], None,
                              "Wrong read-only projects update")
             self.assertEqual(self.db.set_one.call_args[0][1]["_id"], cid, "Wrong CIM identifier")
             self.assertEqual(self.db.set_one.call_args[1]["update_dict"], None,
                              "Wrong read-only projects update")
-            self.assertEqual(self.db.set_one.call_args[1]["pull"], {"_admin.projects_read." + test_pid: None,
-                                                                    "_admin.projects_write." + test_pid: None},
+            self.assertEqual(self.db.set_one.call_args[1]["pull_list"],
+                             {"_admin.projects_read": (test_pid,), "_admin.projects_write": (test_pid,)},
                              "Wrong read/write projects update")
             self.topic._send_msg.assert_not_called()
         with self.subTest(i=2):
                              "Wrong read/write projects update")
             self.topic._send_msg.assert_not_called()
         with self.subTest(i=2):