2
2
3
3
import deepdiff .diff
4
4
import pytest
5
+ from fastapi import HTTPException
5
6
from pytest_mock import MockerFixture
6
7
from routers .openml .flows import flow_exists
7
8
from sqlalchemy import Connection
8
9
from starlette .testclient import TestClient
9
10
10
- from tests .database . flows_test import Flow
11
+ from tests .conftest import Flow
11
12
12
13
13
14
@pytest .mark .parametrize (
@@ -36,7 +37,7 @@ def test_flow_exists_calls_db_correctly(
36
37
"flow_id" ,
37
38
[1 , 2 ],
38
39
)
39
- def test_flow_exists_handles_flow_found (
40
+ def test_flow_exists_processes_found (
40
41
flow_id : int ,
41
42
mocker : MockerFixture ,
42
43
expdb_test : Connection ,
@@ -50,27 +51,24 @@ def test_flow_exists_handles_flow_found(
50
51
assert response == {"flow_id" : fake_flow .id }
51
52
52
53
53
- def test_flow_exists_handles_flow_not_found (py_api : TestClient , mocker : MockerFixture ) -> None :
54
+ def test_flow_exists_handles_flow_not_found (mocker : MockerFixture , expdb_test : Connection ) -> None :
54
55
mocker .patch ("database.flows.get_by_name" , return_value = None )
55
- response = py_api .get ("/flows/exists/weka.ZeroR/Weka_3.9.0_12024" )
56
- assert response .status_code == http .client .NOT_FOUND
56
+ with pytest .raises (HTTPException ) as error :
57
+ flow_exists ("foo" , "bar" , expdb_test )
58
+ assert error .value .status_code == http .client .NOT_FOUND
59
+ assert error .value .detail == "Flow not found."
57
60
58
61
59
- def test_full_stack_exists (flow : Flow , py_api : TestClient ) -> None :
62
+ def test_flow_exists (flow : Flow , py_api : TestClient ) -> None :
60
63
response = py_api .get (f"/flows/exists/{ flow .name } /{ flow .external_version } " )
61
64
assert response .status_code == http .client .OK
62
65
assert response .json () == {"flow_id" : flow .id }
63
66
64
67
65
- def test_flow_exists (py_api : TestClient ) -> None :
66
- response = py_api .get ("/flows/exists/weka.ZeroR/Weka_3.9.0_12024" )
67
- assert response .status_code == http .client .OK
68
- assert response .json () == {"flow_id" : 1 }
69
-
70
-
71
68
def test_flow_exists_not_exists (py_api : TestClient ) -> None :
72
- response = py_api .get ("/flows/exists/does_not_exist/Weka_3.9.0_12024 " )
69
+ response = py_api .get ("/flows/exists/foo/bar " )
73
70
assert response .status_code == http .client .NOT_FOUND
71
+ assert response .json ()["detail" ] == "Flow not found."
74
72
75
73
76
74
def test_get_flow_no_subflow (py_api : TestClient ) -> None :
0 commit comments