Skip to content

Commit 226f29a

Browse files
committed
Write tests
1 parent fdbfb96 commit 226f29a

File tree

5 files changed

+72
-9
lines changed

5 files changed

+72
-9
lines changed

meorg_client/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ def model_output_query(model_id: str):
285285
click.echo(f"Model Output Name: {name}")
286286

287287

288+
def _parse_benchmarks(ctx, param, value):
289+
if value is not None:
290+
return value.split(",")
291+
292+
288293
@click.command("update")
289294
@click.argument("model_output_id")
290295
@click.option(
@@ -332,6 +337,7 @@ def model_output_query(model_id: str):
332337
is_flag=True,
333338
default=[],
334339
help="",
340+
callback=_parse_benchmarks,
335341
)
336342
def model_output_update(
337343
model_output_id: str,

meorg_client/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,9 @@ def model_output_update(
519519
return self._make_request(
520520
method=mcc.HTTP_PATCH,
521521
endpoint=endpoints.MODEL_OUTPUT_UPDATE,
522-
url_params=dict(id=model_id),
522+
url_path_fields=dict(id=model_id),
523523
data=updated_fields,
524524
)
525-
pass
526525

527526
def model_output_delete(self, model_id: str) -> Union[dict, requests.Response]:
528527
"""

meorg_client/data/openapi.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"/modeloutput": {
9999
"get": {
100-
"summary": "Retieve JSON representation from id or unique name",
100+
"summary": "Retrieve JSON representation using id or unique name",
101101
"description": "Query by MO by id or by unique MO name",
102102
"tags": [
103103
"Model Outputs"
@@ -519,7 +519,8 @@
519519
}
520520
},
521521
"patch": {
522-
"summary": "Replace benchmarks entirely with new list. Up to a max of 3 benchmarks",
522+
"summary": "Change benchmarks associated with MO-EXP",
523+
"decription": "Replace benchmarks entirely with new list. Up to a max of 3 benchmarks",
523524
"tags": [
524525
"Model Outputs"
525526
],
@@ -602,8 +603,8 @@
602603
},
603604
"/modeloutput/{id}/available-experiments": {
604605
"patch": {
605-
"summary": "Add experiments to extend existing set of experiment associations",
606-
"description": "User must have access to the workspace that the experiment is contained",
606+
"summary": "Extend existing set of experiment associations",
607+
"description": "Links a list of new experiments to model output. User must have access to the workspace of the cloned experiment",
607608
"tags": [
608609
"Model Outputs"
609610
],
@@ -673,7 +674,8 @@
673674
}
674675
},
675676
"delete": {
676-
"summary": "Remove an experiment from a MO",
677+
"summary": "Remove an experiment association from a MO",
678+
"description": "Removes an experiment association from MO. Only owners of the MO, or users with admin roles can do so.",
677679
"tags": [
678680
"Model Outputs"
679681
],

meorg_client/tests/test_cli.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ def test_create_model_output(runner: CliRunner, model_profile_id, model_output_n
6565
)
6666

6767
assert result.exit_code == 0
68-
assert type(result.return_value) is str # The new model output
68+
model_output_id = result.return_value
69+
assert type(model_output_id) is str # The new model output
70+
71+
# Used in deletion later
72+
store.set("model_output_id", model_output_id)
6973

7074
# Test newly created model_output_id
71-
test_model_output_query(runner, result.return_value)
75+
test_model_output_query(runner, model_output_id)
7276

7377

7478
def test_model_output_query(runner: CliRunner, model_output_id: str):
@@ -80,6 +84,33 @@ def test_model_output_query(runner: CliRunner, model_output_id: str):
8084
assert result.exit_code == 0
8185

8286

87+
def test_model_output_update(
88+
runner: CliRunner,
89+
model_output_name: str,
90+
model_profile_id: str,
91+
):
92+
"""Test Existing Model output."""
93+
result = runner.invoke(
94+
cli.model_output_update,
95+
[
96+
store.get("model_output_id"),
97+
model_output_name,
98+
model_profile_id,
99+
"default",
100+
"automated",
101+
"meorg test model output",
102+
False,
103+
[],
104+
],
105+
)
106+
assert result.exit_code == 0
107+
108+
109+
def test_model_output_delete(runner: CliRunner):
110+
result = runner.invoke(cli.model_output_delete, [store.get("model_output_id")])
111+
assert result.exit_code == 0
112+
113+
83114
def test_file_upload(runner: CliRunner, test_filepath: str, model_output_id: str):
84115
"""Test file-upload via CLI.
85116

meorg_client/tests/test_client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_create_model_output(
103103
model_output_id = response.get("data").get("modeloutput")
104104
assert model_output_id is not None
105105

106+
store.set("model_output_id", model_output_id)
106107
test_model_output_query(client, model_output_id)
107108

108109

@@ -115,6 +116,30 @@ def test_model_output_query(client: Client, model_output_id: str):
115116
assert response_model_output_data.get("id") == model_output_id
116117

117118

119+
def test_model_output_update(
120+
client: Client,
121+
model_profile_id: str,
122+
):
123+
"""Test updation of model output."""
124+
125+
update_data = {
126+
"name": "temp_name",
127+
"model": model_profile_id,
128+
"state_selection": "default model initialisation",
129+
"parameter_selection": "automated calibration",
130+
"comments": "default model initialisation",
131+
"is_bundle": False,
132+
"benchmarks": [],
133+
}
134+
_ = client.model_output_update(store.get("model_output_id"), update_data)
135+
assert client.success()
136+
137+
138+
def test_model_output_delete(client: Client):
139+
_ = client.model_output_query(store.get("model_output_id"))
140+
assert client.success()
141+
142+
118143
def test_upload_file(client: Client, test_filepath: str, model_output_id: str):
119144
"""Test the uploading of a file.
120145

0 commit comments

Comments
 (0)