Пример #1
0
def test_get_path_up(load_mock):
    """
    Test that recursive config loading only reads upwards.
    """
    serverless_helpers.load_envs(__file__)
    prev_call = '/'
    for call in load_mock.call_args_list:
        assert call[0][0].startswith(prev_call.replace('.env', ''))
        prev_call = call[0][0]
Пример #2
0
def test_more_specific_dirs_override(tmpdir):
    """
    Test that .env files closer to the starting dir override
    environments that are higher in the heirarchy
    """
    base = tmpdir.join('.env')
    base.write('OVERRIDE_ME=dev\nCONST=foo')

    serverless_helpers.load_envs(os.path.join(str(tmpdir), 'file.py'))
    assert os.getenv('OVERRIDE_ME') == 'dev'
    assert os.getenv('CONST') == 'foo'

    override = tmpdir.mkdir('first').join('.env')
    override.write('OVERRIDE_ME=prod')

    serverless_helpers.load_envs(os.path.join(str(tmpdir), 'first', 'file.py'))
    assert os.getenv('CONST') == 'foo'
    assert os.getenv('OVERRIDE_ME') == 'prod'