1
+ import base64
1
2
import pytest
2
3
import pytest_asyncio
3
4
import uuid
@@ -1358,7 +1359,8 @@ async def test_fulfill_request_with_all_params(self, tab):
1358
1359
request_id = 'test_request_complete'
1359
1360
response_code = 200
1360
1361
response_headers = [{'name' : 'Content-Type' , 'value' : 'application/json' }]
1361
- body = '{"status": "success", "data": "test"}'
1362
+ json_response = '{"status": "success", "data": "test"}'
1363
+ body = base64 .b64encode (json_response .encode ('utf-8' )).decode ('utf-8' )
1362
1364
response_phrase = 'OK'
1363
1365
1364
1366
await tab .fulfill_request (
@@ -1390,7 +1392,8 @@ async def test_fulfill_request_with_different_status_code(self, tab):
1390
1392
request_id = 'test_request_404'
1391
1393
response_code = 404
1392
1394
response_headers = [{'name' : 'Content-Type' , 'value' : 'text/html' }]
1393
- response_body = {'error' : 'Not Found' }
1395
+ html_response = '<html><body><h1>404 - Not Found</h1></body></html>'
1396
+ response_body = base64 .b64encode (html_response .encode ('utf-8' )).decode ('utf-8' )
1394
1397
1395
1398
await tab .fulfill_request (
1396
1399
request_id , response_code , response_headers , response_body
@@ -1411,7 +1414,8 @@ async def test_fulfill_request_empty_headers(self, tab):
1411
1414
request_id = 'test_request_empty_headers'
1412
1415
response_code = 200
1413
1416
response_headers = []
1414
- response_body = {'message' : 'success' }
1417
+ json_response = '{"message": "success"}'
1418
+ response_body = base64 .b64encode (json_response .encode ('utf-8' )).decode ('utf-8' )
1415
1419
1416
1420
await tab .fulfill_request (
1417
1421
request_id , response_code , response_headers , response_body
@@ -1423,6 +1427,7 @@ async def test_fulfill_request_empty_headers(self, tab):
1423
1427
call_args = tab ._connection_handler .execute_command .call_args_list [- 1 ]
1424
1428
command = call_args [0 ][0 ]
1425
1429
assert command ['params' ]['responseHeaders' ] == []
1430
+ assert command ['params' ]['body' ] == response_body
1426
1431
1427
1432
1428
1433
class TestTabEdgeCases :
0 commit comments