OSMENG-987: Implement PrepareVnfWorkflow
Change-Id: Icf3ccfd44160fbc3f2f2d9ec64e360c07fc9bbfa
Signed-off-by: Dario Faccin <dario.faccin@canonical.com>
diff --git a/osm_lcm/tests/test_vnf_activities.py b/osm_lcm/tests/test_vnf_activities.py
new file mode 100644
index 0000000..989a647
--- /dev/null
+++ b/osm_lcm/tests/test_vnf_activities.py
@@ -0,0 +1,48 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import asynctest
+from osm_common.dataclasses.temporal_dataclasses import VnfInstantiateInput
+from osm_common.dbbase import DbException
+from osm_lcm.temporal.vnf_activities import VnfDbActivity
+from temporalio.testing import ActivityEnvironment
+from unittest.mock import Mock
+
+
+vnfr_uuid = "d08d2da5-2120-476c-8538-deaeb4e88b3e"
+model_name = "a-model-name"
+vnf_instantiate_input = VnfInstantiateInput(vnfr_uuid=vnfr_uuid, model_name=model_name)
+
+
+class TestVnfDbActivity(asynctest.TestCase):
+ def setUp(self):
+ self.db = Mock()
+ self.env = ActivityEnvironment()
+ self.vnf_db_activity = VnfDbActivity(self.db)
+
+ async def test_set_vnf_model(self):
+ await self.env.run(self.vnf_db_activity.set_vnf_model, vnf_instantiate_input)
+ self.db.set_one.assert_called_with(
+ "vnfrs", {"_id": vnfr_uuid}, {"namespace": model_name}
+ )
+
+ async def test_db_raises_exception(self):
+ self.db.set_one.side_effect = DbException("not found")
+ with self.assertRaises(DbException):
+ await self.env.run(
+ self.vnf_db_activity.set_vnf_model, vnf_instantiate_input
+ )