Skip to content
Snippets Groups Projects

[Webservice] Enable two runs detectors

Merged Karim Ahmed requested to merge enable_two_runs_detectors into master
Files
4
+ 24
5
from collections import namedtuple
import datetime as dt
import logging
import sys
import datetime as dt
from collections import namedtuple
from pathlib import Path
from unittest import mock
import pytest
from webservice.webservice import decide_run_parameters
sys.path.insert(0, Path(__file__).parent / 'webservice')
import webservice # noqa: import not at top of file
from webservice.messages import MigrationError # noqa: import not at top
from webservice.webservice import ( # noqa: import not at top of file
check_files,
check_run_type_skip,
config,
get_slurm_nice,
get_slurm_partition,
merge,
parse_config,
run_action,
wait_on_transfer,
get_slurm_partition,
get_slurm_nice,
config,
)
VALID_BEAMTIME = {
@@ -444,3 +446,20 @@ async def test_skip_runs_exception(return_value, status_code, caplog):
assert "run information does not contain expected key" in caplog.text
# And `False` should be returned
assert ret == False
def test_decide_run_parameters_single_run():
assert decide_run_parameters([123], 1) == {'run': 123}
def test_decide_run_parameters_three_runs():
expected = {'run-high': 1, 'run-med': 2, 'run-low': 3}
assert decide_run_parameters([1, 2, 3], 3) == expected
def test_decide_run_parameters_mismatched_runs():
with pytest.raises(ValueError):
decide_run_parameters([1, 2, 3, 4], 3)
with pytest.raises(ValueError):
decide_run_parameters([1, 2], 3)
Loading