def test_change_app_fullname( self, mock_murano_package_manager__write_to_file, mock_murano_package_manager__read_from_file): manifest = {"FullName": "app.name_abc", "Classes": {"app.name_abc": "app_class.yaml"}} mock_murano_package_manager__read_from_file.side_effect = ( [manifest]) utility = utils.MuranoPackageManager({"uuid": "fake_task_id"}) utility._change_app_fullname("tmp/tmpfile/") mock_murano_package_manager__read_from_file.assert_has_calls( [mock.call("tmp/tmpfile/manifest.yaml")] ) mock_murano_package_manager__write_to_file.assert_has_calls( [mock.call(manifest, "tmp/tmpfile/manifest.yaml")] )
def test_prepare_zip_if_not_zip( self, mock_shutil_rmtree, mock_pack_dir, mock_murano_package_manager__change_app_fullname, mock_shutil_copytree, mock_tempfile_mkdtemp, mock_zipfile_is_zipfile): utility = utils.MuranoPackageManager({"uuid": "fake_task_id"}) package_path = "tmp/tmpfile" mock_zipfile_is_zipfile.return_value = False mock_tempfile_mkdtemp.return_value = "tmp/tmpfile" mock_pack_dir.return_value = "tmp/tmpzipfile" zip_file = utility._prepare_package(package_path) self.assertEqual("tmp/tmpzipfile", zip_file) mock_tempfile_mkdtemp.assert_called_once_with() mock_shutil_copytree.assert_called_once_with("tmp/tmpfile", "tmp/tmpfile/package/") (mock_murano_package_manager__change_app_fullname. assert_called_once_with("tmp/tmpfile/package/")) mock_shutil_rmtree.assert_called_once_with("tmp/tmpfile")
def test_prepare_zip_if_zip(self, mock_zipfile_is_zipfile): utility = utils.MuranoPackageManager({"uuid": "fake_task_id"}) package_path = "tmp/tmpfile.zip" mock_zipfile_is_zipfile.return_value = True zip_file = utility._prepare_package(package_path) self.assertEqual("tmp/tmpfile.zip", zip_file)
def test_read_from_file(self, mock_open): utility = utils.MuranoPackageManager({"uuid": "fake_task_id"}) data = utility._read_from_file("filename") expected_data = {"Key": "value"} self.assertEqual(expected_data, data)