mirror of
https://gitflic.ru/project/maks1ms/ocab.git
synced 2025-04-04 08:33:47 +03:00
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
import unittest
|
|
|
|
from src.modules.standard.config.config import get_config
|
|
|
|
yaml_load = get_config(is_test=True)
|
|
|
|
|
|
class TestConfig(unittest.TestCase):
|
|
def test_yaml_load_correctness(self):
|
|
self.assertIsNotNone(yaml_load)
|
|
self.assertIn("TELEGRAM", yaml_load)
|
|
self.assertIn("TOKEN", yaml_load["TELEGRAM"])
|
|
self.assertIn("ROLES", yaml_load)
|
|
self.assertIn("ADMIN", yaml_load["ROLES"])
|
|
self.assertIn("MODERATOR", yaml_load["ROLES"])
|
|
self.assertIn("USER", yaml_load["ROLES"])
|
|
self.assertIn("BOT", yaml_load["ROLES"])
|
|
|
|
def test_yaml_keys_existence(self):
|
|
self.assertTrue(all(key in yaml_load for key in ["TELEGRAM", "ROLES"]))
|
|
self.assertIn("TOKEN", yaml_load["TELEGRAM"])
|
|
self.assertTrue(
|
|
all(role in yaml_load["ROLES"] for role in ["ADMIN", "MODERATOR", "USER"])
|
|
)
|
|
|
|
def test_yaml_yaml_load_types(self):
|
|
self.assertIsInstance(yaml_load["TELEGRAM"]["TOKEN"], str)
|
|
self.assertTrue(
|
|
all(
|
|
isinstance(yaml_load["ROLES"][role], int)
|
|
for role in ["ADMIN", "MODERATOR", "USER"]
|
|
)
|
|
)
|
|
|
|
def test_yaml_values(self):
|
|
expected_token = "xxxxxxxxxxxxxxxxxxxx" # nosec
|
|
expected_role_values = {"ADMIN": 0, "MODERATOR": 1, "USER": 2, "BOT": 3}
|
|
|
|
self.assertEqual(yaml_load["TELEGRAM"]["TOKEN"], expected_token)
|
|
for role, value in expected_role_values.items():
|
|
self.assertEqual(yaml_load["ROLES"][role], value)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|