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

8 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-06 00:35 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5""" 

6Tests helpers for mlos_bench.services.remote.azure. 

7""" 

8from io import BytesIO 

9 

10import json 

11import urllib3 

12 

13 

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

15 """ 

16 Prepare a json response object for use with urllib3 

17 """ 

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

19 response = urllib3.HTTPResponse( 

20 status=status, 

21 body=BytesIO(data), 

22 preload_content=False, 

23 ) 

24 return response