Coverage for mlos_bench/mlos_bench/tests/config/globals/test_load_global_config_examples.py: 100%
18 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Tests for loading globals config examples.
7"""
8import logging
9from typing import List
11import pytest
13from mlos_bench.tests.config import locate_config_examples, BUILTIN_TEST_CONFIG_PATH
15from mlos_bench.config.schemas import ConfigSchema
16from mlos_bench.services.config_persistence import ConfigPersistenceService
19_LOG = logging.getLogger(__name__)
20_LOG.setLevel(logging.DEBUG)
23# Get the set of configs to test.
24CONFIG_TYPE = "globals"
27def filter_configs(configs_to_filter: List[str]) -> List[str]:
28 """If necessary, filter out json files that aren't for the module we're testing."""
29 return configs_to_filter
32configs = [
33 # *locate_config_examples(ConfigPersistenceService.BUILTIN_CONFIG_PATH, CONFIG_TYPE, filter_configs),
34 *locate_config_examples(ConfigPersistenceService.BUILTIN_CONFIG_PATH, "experiments", filter_configs),
35 *locate_config_examples(BUILTIN_TEST_CONFIG_PATH, CONFIG_TYPE, filter_configs),
36 *locate_config_examples(BUILTIN_TEST_CONFIG_PATH, "experiments", filter_configs),
37]
38assert configs
41@pytest.mark.parametrize("config_path", configs)
42def test_load_globals_config_examples(config_loader_service: ConfigPersistenceService, config_path: str) -> None:
43 """Tests loading a config example."""
44 config = config_loader_service.load_config(config_path, ConfigSchema.GLOBALS)
45 assert isinstance(config, dict)