1
1
from fastapi .testclient import TestClient
2
- from unittest .mock import patch
3
2
from main import app
4
3
import json
5
4
8
7
client = TestClient (app )
9
8
10
9
11
- def test_search_issues (s3_bucket , duckdb_connection ):
10
+ def test_search_issues (s3_bucket ):
12
11
# Prepare test params
13
12
params = {
14
13
"dataset" : "conservation-area" ,
@@ -17,8 +16,7 @@ def test_search_issues(s3_bucket, duckdb_connection):
17
16
}
18
17
19
18
# Test the function that interacts with DuckDB and S3 via LocalStack
20
- with patch ("db.duckdb.connect" , return_value = duckdb_connection ):
21
- response = client .get ("/log/issue" , params = params )
19
+ response = client .get ("/log/issue" , params = params )
22
20
23
21
# Validate the results from the search
24
22
assert response .status_code == 200
@@ -35,13 +33,12 @@ def test_search_issues(s3_bucket, duckdb_connection):
35
33
)
36
34
37
35
38
- def test_search_issues_no_parameters (duckdb_connection ):
36
+ def test_search_issues_no_parameters ():
39
37
# Prepare test params
40
38
params = {}
41
39
42
40
# Test the function that interacts with DuckDB and S3 via LocalStack
43
- with patch ("db.duckdb.connect" , return_value = duckdb_connection ):
44
- response = client .get ("/log/issue" , params = params )
41
+ response = client .get ("/log/issue" , params = params )
45
42
46
43
response_json = json .loads (response .content .decode ("utf-8" ))
47
44
details = response_json .get ("detail" , [])
@@ -52,17 +49,15 @@ def test_search_issues_no_parameters(duckdb_connection):
52
49
)
53
50
54
51
55
- def test_provision_summary (s3_bucket , duckdb_connection ):
52
+ def test_provision_summary (s3_bucket ):
56
53
# Prepare test params
57
54
params = {
58
55
"organisation" : "local-authority:BDG" ,
59
56
"offset" : 0 ,
60
57
"limit" : 8 ,
61
58
}
62
59
63
- with patch ("db.duckdb.connect" , return_value = duckdb_connection ):
64
- # Test the function that interacts with DuckDB and S3 via LocalStack
65
- response = client .get ("/performance/provision_summary" , params = params )
60
+ response = client .get ("/performance/provision_summary" , params = params )
66
61
67
62
# Validate the results from the search
68
63
assert response .status_code == 200
@@ -75,16 +70,14 @@ def test_provision_summary(s3_bucket, duckdb_connection):
75
70
assert len (response_data ) > 0
76
71
77
72
78
- def test_specification (s3_bucket , duckdb_connection ):
73
+ def test_specification (s3_bucket ):
79
74
# Prepare test params
80
75
params = {
81
76
"offset" : 0 ,
82
77
"limit" : 8 ,
83
78
}
84
79
85
- with patch ("db.duckdb.connect" , return_value = duckdb_connection ):
86
- # Test the function that interacts with DuckDB and S3 via LocalStack
87
- response = client .get ("/specification/specification" , params = params )
80
+ response = client .get ("/specification/specification" , params = params )
88
81
89
82
# Validate the results from the search
90
83
assert response .status_code == 200
0 commit comments