20 lines
695 B
Python
20 lines
695 B
Python
import os
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from user_engine.runtime import _required
|
|
|
|
|
|
class RequiredRuntimeValueTests(unittest.TestCase):
|
|
def test_normalizes_secret_file_newline(self):
|
|
with patch.dict(os.environ, {"USER_ENGINE_TEST_SECRET": "secret-value\n"}):
|
|
self.assertEqual(_required("USER_ENGINE_TEST_SECRET"), "secret-value")
|
|
|
|
def test_rejects_whitespace_only_value(self):
|
|
with patch.dict(os.environ, {"USER_ENGINE_TEST_SECRET": " \n\t"}):
|
|
with self.assertRaisesRegex(RuntimeError, "USER_ENGINE_TEST_SECRET is required"):
|
|
_required("USER_ENGINE_TEST_SECRET")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|