- self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
- self.assertIn(norm("df[id='{}']:scaling-aspect[id='{}']:scaling-config-action:vnf-"
- "config-primitive-name-ref='{}' does not match any "
- "vnf-configuration:config-primitive:name"
- .format(df["id"], affected_sa["id"], affected_sca_primitive)),
- norm(str(e.exception)), "Wrong exception text")
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ norm(
+ "df[id='{}']:scaling-aspect[id='{}']:scaling-config-action:vnf-"
+ "config-primitive-name-ref='{}' does not match any "
+ "day1-2 configuration:config-primitive:name".format(
+ df["id"], affected_sa["id"], affected_sca_primitive
+ )
+ ),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+
+ def test_new_vnfd_revision(self):
+ did = db_vnfd_content["_id"]
+ self.fs.get_params.return_value = {}
+ self.fs.file_exists.return_value = False
+ self.fs.file_open.side_effect = lambda path, mode: open(
+ "/tmp/" + str(uuid4()), "a+b"
+ )
+ test_vnfd = deepcopy(db_vnfd_content)
+ del test_vnfd["_id"]
+ del test_vnfd["_admin"]
+ self.db.create.return_value = did
+ rollback = []
+ did2, oid = self.topic.new(rollback, fake_session, {})
+ db_args = self.db.create.call_args[0]
+ self.assertEqual(db_args[1]['_admin']['revision'], 0,
+ "New package should be at revision 0")
+
+ @patch("osm_nbi.descriptor_topics.shutil")
+ @patch("osm_nbi.descriptor_topics.os.rename")
+ def test_update_vnfd(self, mock_rename, mock_shutil):
+ old_revision = 5
+ did = db_vnfd_content["_id"]
+ self.fs.path = ""
+ self.fs.get_params.return_value = {}
+ self.fs.file_exists.return_value = False
+ self.fs.file_open.side_effect = lambda path, mode: open(
+ "/tmp/" + str(uuid4()), "a+b"
+ )
+ new_vnfd = deepcopy(db_vnfd_content)
+ del new_vnfd["_id"]
+ self.db.create.return_value = did
+ rollback = []
+ did2, oid = self.topic.new(rollback, fake_session, {})
+ del new_vnfd["vdu"][0]["cloud-init-file"]
+ del new_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"][
+ "day1-2"][0]["execution-environment-list"][0]["juju"]