Skip to content

Commit

Permalink
Restore original "mixed" function signature, for compatibility...
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Aug 8, 2024
1 parent 39b411b commit 8e069da
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
6 changes: 3 additions & 3 deletions runregistry/runregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,12 @@ def move_runs(from_, to_, run=None, runs=[], **kwargs):

if run:
payload = json.dumps({"run_number": run})
return [requests.post(url, headers=headers, data=payload)]
return requests.post(url, headers=headers, data=payload)

answers = []
for run_number in runs:
payload = json.dumps({"run_number": run_number})
answer = requests.post(url, headers=headers, data=payload).json()
answer = requests.post(url, headers=headers, data=payload)
answers.append(answer)

return answers
Expand All @@ -453,7 +453,7 @@ def make_significant_runs(run=None, runs=[], **kwargs):

if run:
data = {"run_number": run}
return [requests.post(url, headers=headers, json=data)]
return requests.post(url, headers=headers, json=data)

answers = []
for run_number in runs:
Expand Down
30 changes: 26 additions & 4 deletions tests/test_advanced_rr_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ def test_move_datasets(setup_runregistry):
assert all([answer.status_code == 401 for answer in answers])


def test_make_significant_runs(setup_runregistry):
def test_make_significant_single_run(setup_runregistry):
# Get latest run in dev runregistry and make it significant
run = runregistry.get_runs(limit=1, filter={})[0]
answers = runregistry.make_significant_runs(run=run["run_number"])
answer = runregistry.make_significant_runs(run=run["run_number"])
# requires permission
assert answer.status_code == 401


def test_make_significant_multi_runs(setup_runregistry):
# Get latest run in dev runregistry and make it significant
run = runregistry.get_runs(limit=1, filter={})[0]
answers = runregistry.make_significant_runs(runs=[run["run_number"]])
# requires permission
assert all([answer.status_code == 401 for answer in answers])

Expand Down Expand Up @@ -86,8 +94,22 @@ def test_move_runs_no_run_arg(setup_runregistry):
runregistry.move_runs("OPEN", "SIGNOFF")


def test_move_runs(setup_runregistry):
answers = runregistry.move_runs("OPEN", "SIGNOFF", run=VALID_RUN_NUMBER)
def test_move_single_run(setup_runregistry):
"""
Unfortunately, this function was given a dual signature, and can return
both a single or a list of request responses.
"""
answer = runregistry.move_runs("OPEN", "SIGNOFF", run=VALID_RUN_NUMBER)
# Requires permission
assert answer.status_code == 401


def test_move_multi_runs(setup_runregistry):
"""
Unfortunately, this function was given a dual signature, and can return
both a single or a list of request responses.
"""
answers = runregistry.move_runs("OPEN", "SIGNOFF", runs=[VALID_RUN_NUMBER])
# Requires permission
assert all([answer.status_code == 401 for answer in answers])

Expand Down

0 comments on commit 8e069da

Please sign in to comment.