Skip to content

Commit f90ece8

Browse files
author
zkan
committed
Test when env format is invalid, it should not set env
1 parent 1627df7 commit f90ece8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

test/test_config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@ def test_initialization(self):
4141
for key in keys:
4242
self.assertTrue(key in self.config.keys)
4343

44-
def test_init_environment(self):
44+
def test_init_environment_should_set_env_from_dotenv(self):
4545
config_file = sendgrid.helpers.inbound.config.__file__
4646
env_file_path = os.path.abspath(os.path.dirname(config_file)) + '/.env'
4747
with open(env_file_path, 'w') as f:
4848
f.write('RANDOM_VARIABLE=RANDOM_VALUE')
4949
Config()
5050
os.remove(env_file_path)
5151
self.assertEqual('RANDOM_VALUE', os.environ['RANDOM_VARIABLE'])
52+
53+
def test_init_environment_should_not_set_env_if_format_is_invalid(self):
54+
config_file = sendgrid.helpers.inbound.config.__file__
55+
env_file_path = os.path.abspath(os.path.dirname(config_file)) + '/.env'
56+
with open(env_file_path, 'w') as f:
57+
f.write('RANDOM_VARIABLE=RANDOM_VALUE=ANOTHER_RANDOM_VALUE')
58+
Config()
59+
os.remove(env_file_path)
60+
self.assertIsNone(os.environ.get('RANDOM_VARIABLE'))

0 commit comments

Comments
 (0)