Skip to content

Commit

Permalink
Update tests to reflect new database state
Browse files Browse the repository at this point in the history
  • Loading branch information
PGijsbers committed Nov 30, 2023
1 parent a8fa27a commit e7f0206
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
19 changes: 12 additions & 7 deletions tests/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
NUMBER_OF_DATASETS = 131
NUMBER_OF_DEACTIVATED_DATASETS = 1
NUMBER_OF_DATASETS_IN_PREPARATION = 2
NUMBER_OF_PRIVATE_DATASETS = 1
NUMBER_OF_ACTIVE_DATASETS = 127
PRIVATE_DATASET_ID = {130}
IN_PREPARATION_ID = {1, 33}
DEACTIVATED_DATASETS = {2, 131}
DATASETS = set(range(1, 132))

PRIVATE_DATASET_ID = 130
IN_PREPARATION_ID = [1, 33]
NUMBER_OF_DATASETS = len(DATASETS)
NUMBER_OF_DEACTIVATED_DATASETS = len(DEACTIVATED_DATASETS)
NUMBER_OF_DATASETS_IN_PREPARATION = len(IN_PREPARATION_ID)
NUMBER_OF_PRIVATE_DATASETS = len(PRIVATE_DATASET_ID)
NUMBER_OF_ACTIVE_DATASETS = (
NUMBER_OF_DATASETS - NUMBER_OF_DEACTIVATED_DATASETS - NUMBER_OF_DATASETS_IN_PREPARATION
)
NUMBER_OF_PUBLIC_ACTIVE_DATASETS = NUMBER_OF_ACTIVE_DATASETS - NUMBER_OF_PRIVATE_DATASETS
6 changes: 3 additions & 3 deletions tests/routers/openml/dataset_tag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_dataset_tag_rejects_unauthorized(key: ApiKey, py_api: TestClient) -> No
httpx.Response,
py_api.post(
f"/datasets/tag{apikey}",
json={"data_id": constants.PRIVATE_DATASET_ID, "tag": "test"},
json={"data_id": list(constants.PRIVATE_DATASET_ID)[0], "tag": "test"},
),
)
assert response.status_code == http.client.PRECONDITION_FAILED
Expand All @@ -35,7 +35,7 @@ def test_dataset_tag_rejects_unauthorized(key: ApiKey, py_api: TestClient) -> No
ids=["administrator", "non-owner", "owner"],
)
def test_dataset_tag(key: ApiKey, expdb_test: Connection, py_api: TestClient) -> None:
dataset_id, tag = constants.PRIVATE_DATASET_ID, "test"
dataset_id, tag = list(constants.PRIVATE_DATASET_ID)[0], "test"
response = cast(
httpx.Response,
py_api.post(
Expand All @@ -46,7 +46,7 @@ def test_dataset_tag(key: ApiKey, expdb_test: Connection, py_api: TestClient) ->
assert response.status_code == http.client.OK
assert {"data_tag": {"id": str(dataset_id), "tag": tag}} == response.json()

tags = get_tags(dataset_id=constants.PRIVATE_DATASET_ID, connection=expdb_test)
tags = get_tags(dataset_id=dataset_id, connection=expdb_test)
assert tag in tags


Expand Down
4 changes: 2 additions & 2 deletions tests/routers/openml/datasets_list_datasets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_list(py_api: TestClient) -> None:
@pytest.mark.parametrize(
("status", "amount"),
[
("active", constants.NUMBER_OF_ACTIVE_DATASETS),
("active", constants.NUMBER_OF_PUBLIC_ACTIVE_DATASETS),
("deactivated", constants.NUMBER_OF_DEACTIVATED_DATASETS),
("in_preparation", constants.NUMBER_OF_DATASETS_IN_PREPARATION),
("all", constants.NUMBER_OF_DATASETS - constants.NUMBER_OF_PRIVATE_DATASETS),
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_list_pagination(limit: int | None, offset: int | None, py_api: TestClie
all_ids = [
did
for did in range(1, 1 + constants.NUMBER_OF_DATASETS)
if did not in [constants.PRIVATE_DATASET_ID]
if did not in constants.PRIVATE_DATASET_ID
]

start = 0 if offset is None else offset
Expand Down
2 changes: 1 addition & 1 deletion tests/routers/openml/datasets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _assert_status_update_is_successful(
@pytest.mark.mut()
@pytest.mark.parametrize(
"dataset_id",
[2, 3],
[3, 4],
)
def test_dataset_status_update_active_to_deactivated(dataset_id: int, py_api: TestClient) -> None:
_assert_status_update_is_successful(
Expand Down

0 comments on commit e7f0206

Please sign in to comment.