test/unit_tests/config/config_manager_test.py
croy 82d417b9e6 New StarlingX Automation Framework
Fresh start for the StarlingX automation framework.

Change-Id: Ie265e0791024f45f71faad6315c2b91b022934d1
2024-11-29 16:01:57 -05:00

63 lines
2.3 KiB
Python

from config.configuration_file_locations_manager import ConfigurationFileLocationsManager
from config.configuration_manager import ConfigurationManagerClass
def test_load_config():
"""
Tests that the default configs are loaded successfully
Returns:
"""
configuration_manager = ConfigurationManagerClass()
config_file_locations = ConfigurationFileLocationsManager()
configuration_manager.load_configs(config_file_locations)
assert configuration_manager.get_lab_config() is not None
def test_invalid_lab_config_file():
"""
Tests that a proper error message is given when an incorrect lab config file is used
"""
try:
configuration_manager = ConfigurationManagerClass()
config_file_locations = ConfigurationFileLocationsManager()
config_file_locations.set_lab_config_file('config/lab/files/no_file.json')
configuration_manager.load_configs(config_file_locations)
assert False, "There should be an exception when we load the configs."
except FileNotFoundError as e:
assert str(e.filename) == "config/lab/files/no_file.json"
def test_invalid_logger_config_file():
"""
Tests that a proper error message is given when an incorrect logger config file is used
"""
try:
configuration_manager = ConfigurationManagerClass()
config_file_locations = ConfigurationFileLocationsManager()
config_file_locations.set_logger_config_file('config/logger/files/no_file.json')
configuration_manager.load_configs(config_file_locations)
assert False, "There should be an exception when we load the configs."
except FileNotFoundError as e:
assert str(e.filename) == "config/logger/files/no_file.json"
def test_invalid_database_config_file():
"""
Tests that a proper error message is given when an incorrect database config file is used
"""
try:
configuration_manager = ConfigurationManagerClass()
config_file_locations = ConfigurationFileLocationsManager()
config_file_locations.set_database_config_file('config/database/files/no_file.json5')
configuration_manager.load_configs(config_file_locations)
assert False, "There should be an exception when we load the configs."
except FileNotFoundError as e:
assert str(e.filename) == "config/database/files/no_file.json5"