Coverage for mlos_bench/mlos_bench/tests/services/remote/mock/mock_network_service.py: 100%
7 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""A collection Service functions for mocking managing (Virtual) Networks."""
7from typing import Any, Callable, Dict, List, Optional, Union
9from mlos_bench.services.base_service import Service
10from mlos_bench.services.types.network_provisioner_type import (
11 SupportsNetworkProvisioning,
12)
13from mlos_bench.tests.services.remote.mock import mock_operation
16class MockNetworkService(Service, SupportsNetworkProvisioning):
17 """Mock Network service for testing."""
19 def __init__(
20 self,
21 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 """
27 Create a new instance of mock network services proxy.
29 Parameters
30 ----------
31 config : dict
32 Free-format dictionary that contains the benchmark environment
33 configuration.
34 global_config : dict
35 Free-format dictionary of global parameters.
36 parent : Service
37 Parent service that can provide mixin functions.
38 """
39 super().__init__(
40 config,
41 global_config,
42 parent,
43 self.merge_methods(
44 methods,
45 {
46 name: mock_operation
47 for name in (
48 # SupportsNetworkProvisioning:
49 "provision_network",
50 "deprovision_network",
51 "wait_network_deployment",
52 )
53 },
54 ),
55 )