File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2314,12 +2314,16 @@ async def test_list_relations(self, mock_request):
23142314 Check whether a user is authorized to access an object
23152315 """
23162316
2317+ def mock_check_requests (* args , ** kwargs ):
2318+ body = kwargs .get ("body" )
2319+ tuple_key = body .get ("tuple_key" )
2320+ if tuple_key ["relation" ] == "owner" :
2321+ return mock_response ('{"allowed": false, "resolution": "1234"}' , 200 )
2322+ return mock_response ('{"allowed": true, "resolution": "1234"}' , 200 )
2323+
23172324 # First, mock the response
2318- mock_request .side_effect = [
2319- mock_response ('{"allowed": true, "resolution": "1234"}' , 200 ),
2320- mock_response ('{"allowed": false, "resolution": "1234"}' , 200 ),
2321- mock_response ('{"allowed": true, "resolution": "1234"}' , 200 ),
2322- ]
2325+ mock_request .side_effect = mock_check_requests
2326+
23232327 configuration = self .configuration
23242328 configuration .store_id = store_id
23252329 async with OpenFgaClient (configuration ) as api_client :
Original file line number Diff line number Diff line change @@ -2317,12 +2317,16 @@ def test_list_relations(self, mock_request):
23172317 Check whether a user is authorized to access an object
23182318 """
23192319
2320+ def mock_check_requests (* args , ** kwargs ):
2321+ body = kwargs .get ('body' )
2322+ tuple_key = body .get ('tuple_key' )
2323+ if tuple_key ['relation' ] == "owner" :
2324+ return mock_response ('{"allowed": false, "resolution": "1234"}' , 200 )
2325+ return mock_response ('{"allowed": true, "resolution": "1234"}' , 200 )
2326+
23202327 # First, mock the response
2321- mock_request .side_effect = [
2322- mock_response ('{"allowed": true, "resolution": "1234"}' , 200 ),
2323- mock_response ('{"allowed": false, "resolution": "1234"}' , 200 ),
2324- mock_response ('{"allowed": true, "resolution": "1234"}' , 200 ),
2325- ]
2328+ mock_request .side_effect = mock_check_requests
2329+
23262330 configuration = self .configuration
23272331 configuration .store_id = store_id
23282332 with OpenFgaClient (configuration ) as api_client :
You can’t perform that action at this time.
0 commit comments