Coverage for mlos_bench/mlos_bench/tests/services/remote/mock/mock_network_service.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-21 01:50 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""A collection Service functions for mocking managing (Virtual) Networks.""" 

6 

7from collections.abc import Callable 

8from typing import Any 

9 

10from mlos_bench.services.base_service import Service 

11from mlos_bench.services.types.network_provisioner_type import ( 

12 SupportsNetworkProvisioning, 

13) 

14from mlos_bench.tests.services.remote.mock import mock_operation 

15 

16 

17class MockNetworkService(Service, SupportsNetworkProvisioning): 

18 """Mock Network service for testing.""" 

19 

20 def __init__( 

21 self, 

22 config: dict[str, Any] | None = None, 

23 global_config: dict[str, Any] | None = None, 

24 parent: Service | None = None, 

25 methods: dict[str, Callable] | list[Callable] | None = None, 

26 ): 

27 """ 

28 Create a new instance of mock network services proxy. 

29 

30 Parameters 

31 ---------- 

32 config : dict 

33 Free-format dictionary that contains the benchmark environment 

34 configuration. 

35 global_config : dict 

36 Free-format dictionary of global parameters. 

37 parent : Service 

38 Parent service that can provide mixin functions. 

39 """ 

40 super().__init__( 

41 config, 

42 global_config, 

43 parent, 

44 self.merge_methods( 

45 methods, 

46 { 

47 name: mock_operation 

48 for name in ( 

49 # SupportsNetworkProvisioning: 

50 "provision_network", 

51 "deprovision_network", 

52 "wait_network_deployment", 

53 ) 

54 }, 

55 ), 

56 )