Skip to content

Commit

Permalink
now update tests for that
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Sep 19, 2023
1 parent 2f73f9a commit b944ed2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
33 changes: 11 additions & 22 deletions tests/integration/test_rest_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def ds_rc() -> RestClient:
"base64_file": base64.b64encode(f.read()).decode(encoding="utf-8"),
"filename": f.name,
"creator": "Hank",
"is_admin": True,
}


Expand Down Expand Up @@ -84,7 +83,7 @@ def test_ingest(ds_rc: RestClient) -> None:
snap_resp = ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
{"is_admin": True, "snapshot": snaps[0]["timestamp"]},
{"snapshot": snaps[0]["timestamp"]},
)
assert not snap_resp["previous_snapshot"]
assert snap_resp["current_snapshot"] == snaps[0]
Expand All @@ -96,7 +95,7 @@ def test_ingest(ds_rc: RestClient) -> None:
resp_live = ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
{"is_admin": True},
{},
)
assert resp_live["previous_snapshot"]
assert resp_live["previous_snapshot"] == snaps[0]
Expand All @@ -113,7 +112,7 @@ def test_ingest(ds_rc: RestClient) -> None:
assert len(snaps) == 0
# get live
resp_live = ds_rc.request_seq(
"GET", f"/table/data/{WBS_L1}", {"is_admin": True}
"GET", f"/table/data/{WBS_L1}", {}
)
assert not resp_live["previous_snapshot"]
for inst in set(r["Institution"] for r in resp_live["table"]):
Expand All @@ -133,7 +132,7 @@ def test_ingest(ds_rc: RestClient) -> None:
snap_resp = ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
{"is_admin": True, "snapshot": snaps[0]["timestamp"]},
{"snapshot": snaps[0]["timestamp"]},
)
assert not snap_resp["previous_snapshot"]
for inst in set(r["Institution"] for r in snap_resp["table"]):
Expand All @@ -144,7 +143,7 @@ def test_ingest(ds_rc: RestClient) -> None:
resp_live = ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
{"is_admin": True},
{},
)
assert resp_live["previous_snapshot"]
assert resp_live["previous_snapshot"] == snaps[0]
Expand Down Expand Up @@ -175,7 +174,7 @@ def test_ingest(ds_rc: RestClient) -> None:
resp = ds_rc.request_seq(
"POST",
f"/table/data/{WBS_L1}",
{"base64_file": "123456789", "filename": "foo-file", "is_admin": True},
{"base64_file": "123456789", "filename": "foo-file"},
)


Expand Down Expand Up @@ -286,9 +285,7 @@ class TestTableHandler:
@staticmethod
def test_get_w_bad_args(ds_rc: RestClient) -> None:
"""Test `GET` @ `/table/data` with bad arguments."""
tests: dict[str, dict[str, Any]] = {
"is_admin": {"foo": "bar"},
}
tests: dict[str, dict[str, Any]] = {}
for arg, body_min in tests.items():
with pytest.raises(
requests.exceptions.HTTPError,
Expand All @@ -300,15 +297,7 @@ def test_get_w_bad_args(ds_rc: RestClient) -> None:
body_min,
)

# empty
with pytest.raises(
requests.exceptions.HTTPError,
match=rf"400 Client Error: `is_admin`: \(MissingArgumentError\) .+ for url: {ds_rc.address}/table/data/{WBS_L1}",
):
ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
)


@staticmethod
def _assert_schema(record: uut.DBRecord, has_total_rows: bool = False) -> None:
Expand Down Expand Up @@ -354,7 +343,7 @@ def test_get_schema(self, ds_rc: RestClient) -> None:
"""Test `GET` @ `/table/data`."""
# assert schema in Live Collection
for record in ds_rc.request_seq(
"GET", f"/table/data/{WBS_L1}", {"is_admin": True}
"GET", f"/table/data/{WBS_L1}", {}
)["table"]:
self._assert_schema(record)

Expand All @@ -365,7 +354,7 @@ def test_get_schema(self, ds_rc: RestClient) -> None:
resp = ds_rc.request_seq(
"GET",
f"/table/data/{WBS_L1}",
{"snapshot": snapshot["timestamp"], "is_admin": True},
{"snapshot": snapshot["timestamp"]},
)
for record in resp["table"]:
self._assert_schema(record)
Expand Down Expand Up @@ -541,7 +530,7 @@ def test_institution_values_full_cycle(ds_rc: RestClient) -> None:
assert original_insts
for inst in original_insts:
records = ds_rc.request_seq(
"GET", f"/table/data/{WBS_L1}", {"institution": inst, "is_admin": True}
"GET", f"/table/data/{WBS_L1}", {"institution": inst}
)["table"]
now = int(time.time())
match inst:
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,13 @@ def test_pull_data_table(
"total_rows": False,
"snapshot": "LIVE_COLLECTION",
"restore_id": "",
"is_admin": True,
},
{ # Other values
"institution": "bar",
# "labor": "baz",
"total_rows": True,
"snapshot": "123",
"restore_id": "456789456123",
"is_admin": True,
},
]

Expand Down

0 comments on commit b944ed2

Please sign in to comment.