Skip to content

Commit

Permalink
Added test to check attr value ( notify_on for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeltrankyl committed Dec 11, 2024
1 parent 99c00dc commit 5888664
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'py3dotplus==1.1.0',
'numpy<2',
'rocrate==0.*',
'autosubmitconfigparser==1.0.75',
'autosubmitconfigparser==1.0.76',
'configparser',
'setproctitle',
'invoke>=2.0',
Expand Down
58 changes: 45 additions & 13 deletions test/unit/test_job_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,29 @@
from autosubmit.platforms.psplatform import PsPlatform


def create_job_and_update_parameters(autosubmit_config, experiment_data):
as_conf = autosubmit_config("test-expid", experiment_data)
as_conf.experiment_data = as_conf.deep_normalize(as_conf.experiment_data)
as_conf.experiment_data = as_conf.normalize_variables(as_conf.experiment_data, must_exists=True)
as_conf.experiment_data = as_conf.deep_read_loops(as_conf.experiment_data)
as_conf.experiment_data = as_conf.substitute_dynamic_variables(as_conf.experiment_data)
as_conf.experiment_data = as_conf.parse_data_loops(as_conf.experiment_data)
# Create some jobs
job = Job('A', '1', 0, 1)
platform = PsPlatform(expid='a000', name='DUMMY_PLATFORM', config=as_conf.experiment_data)
job.section = 'RANDOM-SECTION'
job.platform = platform
job.update_parameters(as_conf, {})
return job


@pytest.mark.parametrize('experiment_data, expected_data', [(
{
'JOBS': {
'RANDOM-SECTION': {
'FILE': "test.sh",
'PLATFORM': 'DUMMY_PLATFORM',
'TEST': "%other%"
'TEST': "%other%",
},
},
'PLATFORMS': {
Expand All @@ -36,17 +52,33 @@
}
)])
def test_update_parameters_current_variables(autosubmit_config, experiment_data, expected_data):
as_conf = autosubmit_config("test-expid", experiment_data)
as_conf.experiment_data = as_conf.deep_normalize(as_conf.experiment_data)
as_conf.experiment_data = as_conf.normalize_variables(as_conf.experiment_data, must_exists=True)
as_conf.experiment_data = as_conf.deep_read_loops(as_conf.experiment_data)
as_conf.experiment_data = as_conf.substitute_dynamic_variables(as_conf.experiment_data)
as_conf.experiment_data = as_conf.parse_data_loops(as_conf.experiment_data)
# Create some jobs
job = Job('A', '1', 0, 1)
platform = PsPlatform(expid='a000', name='DUMMY_PLATFORM', config=as_conf.experiment_data)
job.section = 'RANDOM-SECTION'
job.platform = platform
job.update_parameters(as_conf, {})
job = create_job_and_update_parameters(autosubmit_config, experiment_data)
for key, value in expected_data.items():
assert job.parameters[key] == value


@pytest.mark.parametrize('experiment_data, attributes_to_check', [(
{
'JOBS': {
'RANDOM-SECTION': {
'FILE': "test.sh",
'PLATFORM': 'DUMMY_PLATFORM',
'NOTIFY_ON': 'COMPLETED',
},
},
'PLATFORMS': {
'dummy_platform': {
'type': 'ps',
},
},
'ROOTDIR': 'dummy_rootdir',
'LOCAL_TMP_DIR': 'dummy_tmpdir',
'LOCAL_ROOT_DIR': 'dummy_rootdir',
},
{'notify_on': ['COMPLETED']}
)])
def test_update_parameters_attributes(autosubmit_config, experiment_data, attributes_to_check):
job = create_job_and_update_parameters(autosubmit_config, experiment_data)
for attr in attributes_to_check:
assert hasattr(job, attr)
assert getattr(job, attr) == attributes_to_check[attr]

0 comments on commit 5888664

Please sign in to comment.