2023-07-29 16:50:21 +00:00
|
|
|
import os
|
2022-12-08 01:06:34 +00:00
|
|
|
import unittest
|
2023-07-29 16:50:21 +00:00
|
|
|
from tempfile import TemporaryFile
|
2022-12-08 01:06:34 +00:00
|
|
|
|
2023-07-29 16:50:21 +00:00
|
|
|
from settings import Settings
|
2022-12-08 01:06:34 +00:00
|
|
|
import Utils
|
|
|
|
|
|
|
|
|
|
|
|
class TestIDs(unittest.TestCase):
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls) -> None:
|
2023-07-29 16:50:21 +00:00
|
|
|
with TemporaryFile("w+", encoding="utf-8") as f:
|
|
|
|
Settings(None).dump(f)
|
|
|
|
f.seek(0, os.SEEK_SET)
|
2022-12-08 01:06:34 +00:00
|
|
|
cls.yaml_options = Utils.parse_yaml(f.read())
|
|
|
|
|
2023-07-29 16:50:21 +00:00
|
|
|
def test_utils_in_yaml(self) -> None:
|
2023-10-22 11:00:27 +00:00
|
|
|
"""Tests that the auto generated host.yaml has default settings in it"""
|
2023-10-28 17:32:12 +00:00
|
|
|
for option_key, option_set in Settings(None).items():
|
2022-12-08 01:06:34 +00:00
|
|
|
with self.subTest(option_key):
|
|
|
|
self.assertIn(option_key, self.yaml_options)
|
|
|
|
for sub_option_key in option_set:
|
|
|
|
self.assertIn(sub_option_key, self.yaml_options[option_key])
|
|
|
|
|
2023-07-29 16:50:21 +00:00
|
|
|
def test_yaml_in_utils(self) -> None:
|
2023-10-22 11:00:27 +00:00
|
|
|
"""Tests that the auto generated host.yaml shows up in reference calls"""
|
2023-10-28 17:32:12 +00:00
|
|
|
utils_options = Settings(None)
|
2022-12-08 01:06:34 +00:00
|
|
|
for option_key, option_set in self.yaml_options.items():
|
|
|
|
with self.subTest(option_key):
|
|
|
|
self.assertIn(option_key, utils_options)
|
|
|
|
for sub_option_key in option_set:
|
|
|
|
self.assertIn(sub_option_key, utils_options[option_key])
|