11import json
22from datetime import datetime
33
4- import httpx
54import pytest
65import respx
76
2221 ],
2322)
2423def test_query_tickets (kwargs : dict , expected : str , api_client : ApiClient , respx_mock : respx .mock ):
25- respx_mock .post ().mock (
26- return_value = httpx .Response (
27- status_code = httpx .codes .OK ,
28- text = """{"error": null, "result": [3, 2, 1], "id": null}""" ,
29- )
30- )
24+ respx_mock .post ().respond (text = """{"error": null, "result": [3, 2, 1], "id": null}""" )
3125
3226 def get_last_request_params () -> str :
3327 (param ,) = json .loads (respx_mock .calls .last .request .content )["params" ]
@@ -38,12 +32,7 @@ def get_last_request_params() -> str:
3832
3933
4034def test_get_ticket_attachments (api_client : ApiClient , respx_mock : respx .mock ):
41- respx_mock .post ().mock (
42- return_value = httpx .Response (
43- status_code = httpx .codes .OK ,
44- text = get_fixture ("trac-get-ticket-attachments-response.json" ),
45- )
46- )
35+ respx_mock .post ().respond (text = get_fixture ("trac-get-ticket-attachments-response.json" ))
4736
4837 (attachment ,) = api_client .get_ticket_attachments (1 )
4938 assert respx_mock .calls .last .request .content == b'{"id":null,"method":"ticket.listAttachments","params":[1]}'
@@ -58,12 +47,7 @@ def test_get_ticket_attachments(api_client: ApiClient, respx_mock: respx.mock):
5847
5948
6049def test_get_ticket_changelog (api_client : ApiClient , respx_mock : respx .mock ):
61- respx_mock .post ().mock (
62- return_value = httpx .Response (
63- status_code = httpx .codes .OK ,
64- text = get_fixture ("trac-get-ticket-changelog-response.json" ),
65- )
66- )
50+ respx_mock .post ().respond (text = get_fixture ("trac-get-ticket-changelog-response.json" ))
6751
6852 changelog = api_client .get_ticket_changelog (1 )
6953 assert respx_mock .calls .last .request .content == b'{"id":null,"method":"ticket.changeLog","params":[1]}'
@@ -113,12 +97,7 @@ def test_get_ticket_changelog(api_client: ApiClient, respx_mock: respx.mock):
11397
11498
11599def test_get_ticket (api_client : ApiClient , respx_mock : respx .mock ):
116- respx_mock .post ().mock (
117- return_value = httpx .Response (
118- status_code = httpx .codes .OK ,
119- text = get_fixture ("trac-get-ticket-response.json" ),
120- )
121- )
100+ respx_mock .post ().respond (text = get_fixture ("trac-get-ticket-response.json" ))
122101
123102 assert api_client .get_ticket (1 ) == TracTicketProperties (
124103 id = 1 ,
@@ -145,12 +124,7 @@ def test_get_ticket(api_client: ApiClient, respx_mock: respx.mock):
145124
146125
147126def test_get_ticket_last_field_change (api_client : ApiClient , respx_mock : respx .mock ):
148- respx_mock .post ().mock (
149- return_value = httpx .Response (
150- status_code = httpx .codes .OK ,
151- text = get_fixture ("trac-get-ticket-changelog-response.json" ),
152- )
153- )
127+ respx_mock .post ().respond (text = get_fixture ("trac-get-ticket-changelog-response.json" ))
154128
155129 last_comment = api_client .get_ticket_last_field_change (1 , "comment" )
156130 assert last_comment == TracTicketChangelogEntry (
0 commit comments