diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/test/unit/test_config.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/test/unit/test_config.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/test/unit/test_config.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/test/unit/test_config.py b/.venv/lib/python3.12/site-packages/test/unit/test_config.py new file mode 100644 index 00000000..f60306a5 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/test/unit/test_config.py @@ -0,0 +1,60 @@ +import os +import unittest + +import sendgrid.helpers.inbound.config +from sendgrid.helpers.inbound.config import Config + + +class UnitTests(unittest.TestCase): + + def setUp(self): + self.config = Config() + + def test_initialization(self): + endpoint = '/inbound' + port = 5000 + keys = [ + 'from', + 'attachments', + 'headers', + 'text', + 'envelope', + 'to', + 'html', + 'sender_ip', + 'attachment-info', + 'subject', + 'dkim', + 'SPF', + 'charsets', + 'content-ids', + 'spam_report', + 'spam_score', + 'email', + ] + host = 'http://127.0.0.1:5000/inbound' + + self.assertTrue(self.config.debug_mode) + self.assertEqual(self.config.endpoint, endpoint) + self.assertEqual(self.config.host, host) + self.assertEqual(self.config.port, port) + for key in keys: + self.assertIn(key, self.config.keys) + + def test_init_environment_should_set_env_from_dotenv(self): + config_file = sendgrid.helpers.inbound.config.__file__ + env_file_path = '{0}/.env'.format(os.path.abspath(os.path.dirname(config_file))) + with open(env_file_path, 'w') as f: + f.write('RANDOM_VARIABLE=RANDOM_VALUE') + Config() + os.remove(env_file_path) + self.assertEqual(os.environ['RANDOM_VARIABLE'], 'RANDOM_VALUE') + + def test_init_environment_should_not_set_env_if_format_is_invalid(self): + config_file = sendgrid.helpers.inbound.config.__file__ + env_file_path = os.path.abspath(os.path.dirname(config_file)) + '/.env' + with open(env_file_path, 'w') as f: + f.write('RANDOM_VARIABLE=RANDOM_VALUE=ANOTHER_RANDOM_VALUE') + Config() + os.remove(env_file_path) + self.assertIsNone(os.environ.get('RANDOM_VARIABLE')) |