Skip to content

Commit a06b7f6

Browse files
committed
json -> model_dump_json
1 parent bb43c36 commit a06b7f6

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

tests/test_routes/api_calls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def create_subscription_detail(
7171
role_assignments=role_assignments,
7272
)
7373
]
74-
).json(),
74+
).model_dump_json(),
7575
headers={"authorization": "Bearer " + token},
7676
)
7777

@@ -177,6 +177,6 @@ def create_usage(
177177

178178
return client.post(
179179
"usage/all-usage",
180-
content=post_data.json(),
180+
content=post_data.model_dump_json(),
181181
headers={"authorization": "Bearer " + token},
182182
)

tests/test_routes/test_cost_recovery.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_cost_recovery_app_route(
4343
recovery_period = CostRecoveryMonth(first_day=date(year=2001, month=1, day=1))
4444
result = client.post(
4545
PREFIX + "/app-cost-recovery",
46-
content=recovery_period.json(),
46+
content=recovery_period.model_dump_json(),
4747
headers={"authorization": "Bearer " + token},
4848
)
4949

@@ -73,7 +73,7 @@ def test_cost_recovery_cli_route(
7373
recovery_period = CostRecoveryMonth(first_day=date(year=2001, month=1, day=1))
7474
result = client.post(
7575
PREFIX + "/cli-cost-recovery",
76-
content=recovery_period.json(),
76+
content=recovery_period.model_dump_json(),
7777
)
7878

7979
mock.assert_called_once_with(
@@ -99,7 +99,7 @@ def test_cost_recovery_cli_route_dry_run(
9999
result = client.request(
100100
"GET",
101101
PREFIX + "/cli-cost-recovery",
102-
content=recovery_period.json(),
102+
content=recovery_period.model_dump_json(),
103103
)
104104

105105
mock.assert_called_once_with(

tests/test_routes/test_finances.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_finance_route(auth_app: FastAPI) -> None:
4646
result = client.request(
4747
"GET",
4848
PREFIX + "/finance",
49-
content=SubscriptionItem(sub_id=UUID(int=33)).json(),
49+
content=SubscriptionItem(sub_id=UUID(int=33)).model_dump_json(),
5050
)
5151

5252
assert result.status_code == 200
@@ -117,7 +117,7 @@ def test_finances_route(auth_app: FastAPI) -> None:
117117
finance_code="test_finance",
118118
priority=1,
119119
)
120-
result = client.post(PREFIX + "/finances", content=f_a.json())
120+
result = client.post(PREFIX + "/finances", content=f_a.model_dump_json())
121121

122122
assert result.status_code == 201
123123

@@ -364,13 +364,14 @@ def test_finance_post_get_put_delete(auth_app: FastAPI) -> None:
364364
finance_code="test_finance",
365365
priority=1,
366366
)
367-
result = client.post(PREFIX + "/finances", content=f_a.json())
367+
result = client.post(PREFIX + "/finances", content=f_a.model_dump_json())
368368
assert result.status_code == 201
369369
f_a_returned = FinanceWithID.parse_raw(result.content)
370370

371371
f_a_returned.amount = 10.0
372372
result = client.put(
373-
PREFIX + f"/finances/{f_a_returned.id}", content=f_a_returned.json()
373+
PREFIX + f"/finances/{f_a_returned.id}",
374+
content=f_a_returned.model_dump_json(),
374375
)
375376
assert result.status_code == 200
376377

@@ -381,7 +382,7 @@ def test_finance_post_get_put_delete(auth_app: FastAPI) -> None:
381382
result = client.request(
382383
"DELETE",
383384
PREFIX + f"/finances/{f_a_returned.id}",
384-
content=SubscriptionItem(sub_id=constants.TEST_SUB_UUID).json(),
385+
content=SubscriptionItem(sub_id=constants.TEST_SUB_UUID).model_dump_json(),
385386
)
386387
assert result.status_code == 200
387388

@@ -545,19 +546,20 @@ def test_finance_can_update(auth_app: FastAPI) -> None:
545546
finance_code="test_finance",
546547
priority=1,
547548
)
548-
result = client.post(PREFIX + "/finances", content=f_a.json())
549+
result = client.post(PREFIX + "/finances", content=f_a.model_dump_json())
549550
assert result.status_code == 201
550551
f_a_returned = FinanceWithID.parse_raw(result.content)
551552

552553
result = client.post(
553554
PREFIX + "/cli-cost-recovery",
554-
content=CostRecoveryMonth(first_day="2022-09-01").json(),
555+
content=CostRecoveryMonth(first_day="2022-09-01").model_dump_json(),
555556
)
556557
assert result.status_code == 200
557558

558559
f_a_returned.amount = 10.0
559560
result = client.put(
560-
PREFIX + f"/finances/{f_a_returned.id}", content=f_a_returned.json()
561+
PREFIX + f"/finances/{f_a_returned.id}",
562+
content=f_a_returned.model_dump_json(),
561563
)
562564
assert result.status_code == 200
563565

tests/test_routes/test_status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_post_status(
5858

5959
resp = client.post(
6060
"accounting/all-status",
61-
content=all_status.json(),
61+
content=all_status.model_dump_json(),
6262
headers={"authorization": "Bearer " + token},
6363
)
6464
assert resp.status_code == 200
@@ -72,7 +72,7 @@ def test_post_status(
7272
# Check that we can POST the same status again without issue (idempotency).
7373
resp = client.post(
7474
"accounting/all-status",
75-
content=all_status.json(),
75+
content=all_status.model_dump_json(),
7676
headers={"authorization": "Bearer " + token},
7777
)
7878
assert resp.status_code == 200

tests/test_routes/test_usage.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_post_usage(
5353

5454
resp = client.post(
5555
"usage/all-usage",
56-
content=post_data.json(),
56+
content=post_data.model_dump_json(),
5757
headers={"authorization": "Bearer " + token},
5858
)
5959

@@ -221,7 +221,7 @@ def _post_costmanagement(
221221
post_client = client.post(
222222
"/usage/all-cm-usage",
223223
headers={"authorization": "Bearer " + token},
224-
content=all_usage.json(),
224+
content=all_usage.model_dump_json(),
225225
) # type: ignore
226226
return post_client # type: ignore
227227

@@ -300,23 +300,23 @@ def test_post_monthly_usage(
300300

301301
resp = client.post(
302302
"usage/monthly-usage",
303-
content=post_example_1_data.json(),
303+
content=post_example_1_data.model_dump_json(),
304304
headers={"authorization": "Bearer " + token},
305305
)
306306

307307
assert resp.status_code == 400
308308

309309
resp = client.post(
310310
"usage/monthly-usage",
311-
content=post_example_2_data.json(),
311+
content=post_example_2_data.model_dump_json(),
312312
headers={"authorization": "Bearer " + token},
313313
)
314314

315315
assert resp.status_code == 400
316316

317317
resp = client.post(
318318
"usage/monthly-usage",
319-
content=post_example_3_data.json(),
319+
content=post_example_3_data.model_dump_json(),
320320
headers={"authorization": "Bearer " + token},
321321
)
322322

@@ -383,7 +383,7 @@ def test_post_usage_emails(
383383

384384
resp = client.post(
385385
"usage/all-usage",
386-
content=post_data.json(),
386+
content=post_data.model_dump_json(),
387387
headers={"authorization": "Bearer " + token},
388388
)
389389
assert resp.status_code == 200

0 commit comments

Comments
 (0)