Skip to content

Commit da6a891

Browse files
committed
Add migration test for flow_exists
1 parent 3709a3b commit da6a891

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

tests/conftest.py

+19
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,22 @@ def flow(expdb_test: Connection) -> Flow:
8787
)
8888
(flow_id,) = expdb_test.execute(text("""SELECT LAST_INSERT_ID();""")).one()
8989
return Flow(id=flow_id, name="name", external_version="external_version")
90+
91+
92+
@pytest.fixture()
93+
def persisted_flow(flow: Flow, expdb_test: Connection) -> Iterator[Flow]:
94+
expdb_test.commit()
95+
yield flow
96+
# We want to ensure the commit below does not accidentally persist new
97+
# data to the database.
98+
expdb_test.rollback()
99+
expdb_test.execute(
100+
text(
101+
"""
102+
DELETE FROM implementation
103+
WHERE id = :flow_id
104+
""",
105+
),
106+
parameters={"flow_id": flow.id},
107+
)
108+
expdb_test.commit()

tests/routers/openml/migration/flows_migration_test.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
)
1010
from starlette.testclient import TestClient
1111

12+
from tests.conftest import Flow
1213

14+
15+
@pytest.mark.mut()
1316
@pytest.mark.php()
14-
def test_flow_exists(py_api: TestClient, php_api: TestClient) -> None:
15-
path = "exists/weka.ZeroR/Weka_3.9.0_12024"
17+
def test_flow_exists(
18+
persisted_flow: Flow,
19+
py_api: TestClient,
20+
php_api: TestClient,
21+
) -> None:
22+
path = f"exists/{persisted_flow.name}/{persisted_flow.external_version}"
1623
py_response = py_api.get(f"/flows/{path}")
1724
php_response = php_api.get(f"/flow/{path}")
1825

0 commit comments

Comments
 (0)