Coverage for mlos_bench/mlos_bench/tests/services/remote/azure/__init__.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-07 01:52 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""Tests helpers for mlos_bench.services.remote.azure.""" 

6import json 

7from io import BytesIO 

8 

9import urllib3 

10 

11 

12def make_httplib_json_response(status: int, json_data: dict) -> urllib3.HTTPResponse: 

13 """Prepare a json response object for use with urllib3.""" 

14 data = json.dumps(json_data).encode("utf-8") 

15 response = urllib3.HTTPResponse( 

16 status=status, 

17 body=BytesIO(data), 

18 preload_content=False, 

19 ) 

20 return response