Files
gyxx-flow/tests/modules/product_commerce/test_db_config.py
T

43 lines
1.1 KiB
Python

import unittest
from db import build_pg_config
class DatabaseConfigTests(unittest.TestCase):
def test_complete_config_is_parsed(self):
config = build_pg_config(
{
"PG_HOST": "db.example.test",
"PG_PORT": "5544",
"PG_DB": "warehouse",
"PG_USER": "collector",
"PG_PASSWORD": "secret",
}
)
self.assertEqual(
config,
{
"host": "db.example.test",
"port": 5544,
"dbname": "warehouse",
"user": "collector",
"password": "secret",
},
)
def test_missing_final_config_is_rejected(self):
with self.assertRaisesRegex(RuntimeError, "PG_HOST"):
build_pg_config(
{
"PG_PORT": "5432",
"PG_DB": "warehouse",
"PG_USER": "collector",
"PG_PASSWORD": "secret",
}
)
if __name__ == "__main__":
unittest.main()