@@ -72,8 +72,8 @@ def result_pages(status=None, size=40):
7272
7373
7474# The "creation", "update", and "cancel" mock APIs return submitted
75- # data to the caller. They are used to test methods that rely on POST
76- # or PUT.
75+ # data to the caller. They are used to test methods that rely on POST,
76+ # PATCH, or PUT.
7777def modify_response (request ):
7878 if request .content :
7979 return Response (200 , json = json .loads (request .content ))
@@ -89,6 +89,10 @@ def modify_response(request):
8989update_mock .route (M (url = f'{ TEST_URL } /test' ),
9090 method = 'PUT' ).mock (side_effect = modify_response )
9191
92+ patch_mock = respx .mock ()
93+ patch_mock .route (M (url = f'{ TEST_URL } /test' ),
94+ method = 'PATCH' ).mock (side_effect = modify_response )
95+
9296cancel_mock = respx .mock ()
9397cancel_mock .route (M (url = f'{ TEST_URL } /test/cancel' ),
9498 method = 'POST' ).mock (side_effect = modify_response )
@@ -232,14 +236,24 @@ async def test_update_subscription_failure():
232236@pytest .mark .anyio
233237@update_mock
234238async def test_update_subscription_success ():
235- """Subscription is created , description has the expected items."""
239+ """Subscription is updated , description has the expected items."""
236240 async with Session () as session :
237241 client = SubscriptionsClient (session , base_url = TEST_URL )
238242 sub = await client .update_subscription (
239243 "test" , {
240- ' name' : ' test' , ' delivery' : "no, thanks" , ' source' : ' test'
244+ " name" : " test" , " delivery" : "no, thanks" , " source" : " test"
241245 })
242- assert sub ['delivery' ] == "no, thanks"
246+ assert sub ["delivery" ] == "no, thanks"
247+
248+
249+ @pytest .mark .anyio
250+ @patch_mock
251+ async def test_patch_subscription_success ():
252+ """Subscription is patched, description has the expected items."""
253+ async with Session () as session :
254+ client = SubscriptionsClient (session , base_url = TEST_URL )
255+ sub = await client .patch_subscription ("test" , {"name" : "test patch" })
256+ assert sub ["name" ] == "test patch"
243257
244258
245259@pytest .mark .anyio
0 commit comments