|
4 | 4 | import sqlite3 |
5 | 5 |
|
6 | 6 | from dependency_injector import containers |
7 | | -from pytest import mark |
8 | 7 |
|
9 | 8 | from samples.schema.services import UserService, AuthService, PhotoService |
10 | 9 |
|
|
19 | 18 |
|
20 | 19 | def test_single_container_schema(container: containers.DynamicContainer): |
21 | 20 | container.from_yaml_schema(f"{SAMPLES_DIR}/schema/container-single.yml") |
22 | | - container.config.from_dict({ |
23 | | - "database": { |
24 | | - "dsn": ":memory:", |
25 | | - }, |
26 | | - "aws": { |
27 | | - "access_key_id": "KEY", |
28 | | - "secret_access_key": "SECRET", |
29 | | - }, |
30 | | - "auth": { |
31 | | - "token_ttl": 3600, |
32 | | - }, |
33 | | - }) |
| 21 | + container.config.from_dict( |
| 22 | + { |
| 23 | + "database": { |
| 24 | + "dsn": ":memory:", |
| 25 | + }, |
| 26 | + "aws": { |
| 27 | + "access_key_id": "KEY", |
| 28 | + "secret_access_key": "SECRET", |
| 29 | + }, |
| 30 | + "auth": { |
| 31 | + "token_ttl": 3600, |
| 32 | + }, |
| 33 | + }, |
| 34 | + ) |
34 | 35 |
|
35 | 36 | # User service |
36 | 37 | user_service1 = container.user_service() |
@@ -79,18 +80,20 @@ def test_single_container_schema(container: containers.DynamicContainer): |
79 | 80 |
|
80 | 81 | def test_multiple_containers_schema(container: containers.DynamicContainer): |
81 | 82 | container.from_yaml_schema(f"{SAMPLES_DIR}/schema/container-multiple.yml") |
82 | | - container.core.config.from_dict({ |
83 | | - "database": { |
84 | | - "dsn": ":memory:", |
85 | | - }, |
86 | | - "aws": { |
87 | | - "access_key_id": "KEY", |
88 | | - "secret_access_key": "SECRET", |
89 | | - }, |
90 | | - "auth": { |
91 | | - "token_ttl": 3600, |
| 83 | + container.core.config.from_dict( |
| 84 | + { |
| 85 | + "database": { |
| 86 | + "dsn": ":memory:", |
| 87 | + }, |
| 88 | + "aws": { |
| 89 | + "access_key_id": "KEY", |
| 90 | + "secret_access_key": "SECRET", |
| 91 | + }, |
| 92 | + "auth": { |
| 93 | + "token_ttl": 3600, |
| 94 | + }, |
92 | 95 | }, |
93 | | - }) |
| 96 | + ) |
94 | 97 |
|
95 | 98 | # User service |
96 | 99 | user_service1 = container.services.user() |
@@ -139,18 +142,20 @@ def test_multiple_containers_schema(container: containers.DynamicContainer): |
139 | 142 |
|
140 | 143 | def test_multiple_reordered_containers_schema(container: containers.DynamicContainer): |
141 | 144 | container.from_yaml_schema(f"{SAMPLES_DIR}/schema/container-multiple-reordered.yml") |
142 | | - container.core.config.from_dict({ |
143 | | - "database": { |
144 | | - "dsn": ":memory:", |
145 | | - }, |
146 | | - "aws": { |
147 | | - "access_key_id": "KEY", |
148 | | - "secret_access_key": "SECRET", |
149 | | - }, |
150 | | - "auth": { |
151 | | - "token_ttl": 3600, |
| 145 | + container.core.config.from_dict( |
| 146 | + { |
| 147 | + "database": { |
| 148 | + "dsn": ":memory:", |
| 149 | + }, |
| 150 | + "aws": { |
| 151 | + "access_key_id": "KEY", |
| 152 | + "secret_access_key": "SECRET", |
| 153 | + }, |
| 154 | + "auth": { |
| 155 | + "token_ttl": 3600, |
| 156 | + }, |
152 | 157 | }, |
153 | | - }) |
| 158 | + ) |
154 | 159 |
|
155 | 160 | # User service |
156 | 161 | user_service1 = container.services.user() |
@@ -199,18 +204,20 @@ def test_multiple_reordered_containers_schema(container: containers.DynamicConta |
199 | 204 |
|
200 | 205 | def test_multiple_containers_with_inline_providers_schema(container: containers.DynamicContainer): |
201 | 206 | container.from_yaml_schema(f"{SAMPLES_DIR}/schema/container-multiple-inline.yml") |
202 | | - container.core.config.from_dict({ |
203 | | - "database": { |
204 | | - "dsn": ":memory:", |
205 | | - }, |
206 | | - "aws": { |
207 | | - "access_key_id": "KEY", |
208 | | - "secret_access_key": "SECRET", |
209 | | - }, |
210 | | - "auth": { |
211 | | - "token_ttl": 3600, |
| 207 | + container.core.config.from_dict( |
| 208 | + { |
| 209 | + "database": { |
| 210 | + "dsn": ":memory:", |
| 211 | + }, |
| 212 | + "aws": { |
| 213 | + "access_key_id": "KEY", |
| 214 | + "secret_access_key": "SECRET", |
| 215 | + }, |
| 216 | + "auth": { |
| 217 | + "token_ttl": 3600, |
| 218 | + }, |
212 | 219 | }, |
213 | | - }) |
| 220 | + ) |
214 | 221 |
|
215 | 222 | # User service |
216 | 223 | user_service1 = container.services.user() |
@@ -257,7 +264,6 @@ def test_multiple_containers_with_inline_providers_schema(container: containers. |
257 | 264 | assert photo_service2.s3 is container.gateways.s3_client() |
258 | 265 |
|
259 | 266 |
|
260 | | -@mark.skip(reason="Boto3 tries to connect to the internet") |
261 | 267 | def test_schema_with_boto3_session(container: containers.DynamicContainer): |
262 | 268 | container.from_yaml_schema(f"{SAMPLES_DIR}/schema/container-boto3-session.yml") |
263 | 269 | container.config.from_dict( |
|
0 commit comments