Coverage for mlos_bench/mlos_bench/tests/services/remote/mock/mock_network_service.py: 100%
8 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« 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"""
6A collection Service functions for mocking managing (Virtual) Networks.
7"""
9from typing import Any, Callable, Dict, List, Optional, Union
11from mlos_bench.services.base_service import Service
12from mlos_bench.services.types.network_provisioner_type import SupportsNetworkProvisioning
13from mlos_bench.tests.services.remote.mock import mock_operation
16class MockNetworkService(Service, SupportsNetworkProvisioning):
17 """
18 Mock Network service for testing.
19 """
21 def __init__(self, config: Optional[Dict[str, Any]] = None,
22 global_config: Optional[Dict[str, Any]] = None,
23 parent: Optional[Service] = None,
24 methods: Union[Dict[str, Callable], List[Callable], None] = None):
25 """
26 Create a new instance of mock network services proxy.
28 Parameters
29 ----------
30 config : dict
31 Free-format dictionary that contains the benchmark environment
32 configuration.
33 global_config : dict
34 Free-format dictionary of global parameters.
35 parent : Service
36 Parent service that can provide mixin functions.
37 """
38 super().__init__(
39 config, global_config, parent,
40 self.merge_methods(methods, {
41 name: mock_operation for name in (
42 # SupportsNetworkProvisioning:
43 "provision_network",
44 "deprovision_network",
45 "wait_network_deployment",
46 )
47 })
48 )