def test_environment_variable_nonempty_file():
"""Test the encrypt module's CLI function with the --env flag and a nonempty YAML file.
The YAML file includes information that needs to be overwritten."""
runner = CliRunner()
with runner.isolated_filesystem():
initial_data = OrderedDict([('language', 'python'), ('dist', 'trusty'),
('env', {'global': {'secure': 'API_KEY="SUPER_INSECURE_KEY"'}})])
with open('file.yml', 'w') as file:
ordered_dump(initial_data, file)
result = runner.invoke(cli, ['--env', 'mandeep', 'Travis-Encrypt', 'file.yml'],
'SUPER_SECURE_API_KEY')
assert not result.exception
with open('file.yml') as file:
config = ordered_load(file)
assert config['language'] == 'python'
assert config['dist'] == 'trusty'
assert base64.b64decode(config['env']['global']['secure'])
assert ['language', 'dist', 'env'] == [key for key in config.keys()]
评论列表
文章目录