From 10a44af2c2099b0c6b8981ee6dc5e0ad89fe5c7c Mon Sep 17 00:00:00 2001 From: fdekievit Date: Mon, 11 Nov 2024 17:21:14 +0100 Subject: [PATCH] fixed issue where a warning after and error did not propagate the error to the email header --- rsync_to_rdisc.py | 9 +++++---- test_rsync_to_rdisc.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/rsync_to_rdisc.py b/rsync_to_rdisc.py index 5c4917e..4e7ca99 100755 --- a/rsync_to_rdisc.py +++ b/rsync_to_rdisc.py @@ -276,13 +276,14 @@ def run_vcf_upload(vcf_file, vcf_type, run): def get_upload_state(upload_result): + return_value = 'ok' for msg in upload_result: if 'error' in msg.lower(): - return 'error' + return_value = 'error' + break elif 'warning' in msg.lower(): - return 'warning' - return 'ok' - + return_value = 'warning' + return return_value def upload_gatk_vcf(run, run_folder): # Remove projects from run diff --git a/test_rsync_to_rdisc.py b/test_rsync_to_rdisc.py index 2b9c281..a4ea707 100644 --- a/test_rsync_to_rdisc.py +++ b/test_rsync_to_rdisc.py @@ -397,8 +397,18 @@ def test_run_vcf_upload(mocker, set_up_test): (["warning"], "warning"), (["Warning"], "warning"), (["vcf_upload_warning"], "warning"), - (["ok"], "ok") - ]) + (["ok"], "ok"), + (["error", "error"], "error"), + (["warning", "warning"], "warning"), + (["error", "warning"], "error"), + (["warning", "error"], "error"), + (["warning", "ok"], "warning"), + (["ok", "warning"], "warning"), + (["warning", "error", "ok"], "error"), + (["ok", "warning", "ok", "error"], "error"), + (["ok", "warning", "error"], "error"), + (["ok", "error", "warning"], "error") +]) def test_get_upload_state(msg, expected): return_state = rsync_to_rdisc.get_upload_state(msg) assert return_state == expected