Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pyyaml to test_require #2047

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions test/unit/provenance/test_rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from tempfile import TemporaryDirectory
from unittest import TestCase

import yaml
from mock import Mock, patch
from rocrate.rocrate import File
from rocrate.rocrate import ROCrate
from ruamel.yaml import YAML
from ruamel.yaml.representer import RepresenterError

from autosubmit.autosubmit import Autosubmit
from autosubmit.job.job import Job
Expand Down Expand Up @@ -48,7 +49,9 @@ def _create_conf_dir(self, parent, as_conf=None):
Path(conf_dir, 'metadata').mkdir()
unified_config = Path(conf_dir, 'metadata/experiment_data.yml')
unified_config.touch()
unified_config.write_text(yaml.dump(as_conf.experiment_data))
yaml = YAML(typ='rt')
with open(unified_config, 'w') as f:
yaml.dump(dict(as_conf.experiment_data), f)
as_conf.current_loaded_files = {unified_config: 0}

def test_add_dir_and_files_empty_folder(self):
Expand Down Expand Up @@ -428,26 +431,16 @@ def test_rocrate_invalid_parameter_type(
'APP'
]
}
self._create_conf_dir(experiment_path)
jobs = []

mocked_get_autosubmit_version.return_value = '4.0.0b0'
mocked_get_experiment_descrip.return_value = [
['mocked test project']
]

with self.assertRaises(AutosubmitCritical) as cm:
create_rocrate_archive(
as_conf=self.as_conf,
rocrate_json=rocrate_json,
jobs=jobs,
start_time=None,
end_time=None,
path=Path(temp_dir)
)
with self.assertRaises(RepresenterError) as cm:
self._create_conf_dir(experiment_path)

self.assertEqual(cm.exception.message,
'Could not locate a type in RO-Crate for parameter APP.OBJ type object')
self.assertTrue('cannot represent an object' in str(cm.exception))

@patch('autosubmit.autosubmit.Log')
@patch('autosubmit.autosubmit.AutosubmitConfig')
Expand Down
Loading