Skip to content

Commit

Permalink
adapted and extended test
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Oct 23, 2023
1 parent 552f4ff commit f6c7b21
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/test_job_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,8 @@ def test_free_up_space(dispatcher_live_fixture, number_folders_to_delete, soft_m
@pytest.mark.parametrize("request_cred", ['public', 'private', 'invalid_token'])
@pytest.mark.parametrize("roles", ["general, job manager", "administrator", ""])
@pytest.mark.parametrize("include_session_log", [True, False, None])
def test_inspect_status(dispatcher_live_fixture, request_cred, roles, include_session_log):
@pytest.mark.parametrize("remove_analysis_parameters_json", [True, False])
def test_inspect_status(dispatcher_live_fixture, request_cred, roles, include_session_log, remove_analysis_parameters_json):
required_roles = ['job manager']
DispatcherJobState.remove_scratch_folders()

Expand Down Expand Up @@ -2521,6 +2522,8 @@ def test_inspect_status(dispatcher_live_fixture, request_cred, roles, include_se
session_id = jdata['session_id']

scratch_dir_fn = f'scratch_sid_{session_id}_jid_{job_id}'
if remove_analysis_parameters_json:
os.remove(os.path.join(scratch_dir_fn, "analysis_parameters.json"))
scratch_dir_ctime = os.stat(scratch_dir_fn).st_ctime

assert os.path.exists(scratch_dir_fn)
Expand Down Expand Up @@ -2565,15 +2568,18 @@ def test_inspect_status(dispatcher_live_fixture, request_cred, roles, include_se
assert jdata['records'][0]['ctime'] == scratch_dir_ctime
assert jdata['records'][0]['mtime'] == scratch_dir_mtime

assert 'email_history' in jdata['records'][0]['analysis_parameters']
assert 'matrix_message_history' in jdata['records'][0]['analysis_parameters']
assert 'analysis_parameters' in jdata['records'][0]
if remove_analysis_parameters_json:
assert jdata['records'][0]['analysis_parameters'] == f"problem reading {os.path.join(scratch_dir_fn, 'analysis_parameters.json')}: FileNotFoundError(2, 'No such file or directory')"
assert 'email_history' in jdata['records'][0]
assert 'matrix_message_history' in jdata['records'][0]

assert len(jdata['records'][0]['analysis_parameters']['email_history']) == 0
assert len(jdata['records'][0]['analysis_parameters']['matrix_message_history']) == 0
assert len(jdata['records'][0]['email_history']) == 0
assert len(jdata['records'][0]['matrix_message_history']) == 0
if include_session_log:
assert 'session_log' in jdata['records'][0]['analysis_parameters']
assert 'session_log' in jdata['records'][0]
else:
assert 'session_log' not in jdata['records'][0]['analysis_parameters']
assert 'session_log' not in jdata['records'][0]

assert 'file_list' in jdata['records'][0]
assert isinstance(jdata['records'][0]['file_list'], list)
Expand Down

0 comments on commit f6c7b21

Please sign in to comment.