Skip to content

Commit

Permalink
Version 1.1.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Sep 10, 2019
1 parent 50324d5 commit ff70118
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 89 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
We follow semantic versioning.


## Version 1.1.1

### Bugfixes

- Outputs errors to `stderr` instead of `stdout`


## Version 1.1.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion dump_env/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main() -> NoReturn:
try:
variables = dump(args.template, args.prefix, strict_vars)
except StrictEnvException as exc:
sys.stdout.write('{0}\n'.format(str(exc)))
sys.stderr.write('{0}\n'.format(str(exc)))
sys.exit(1)
else:
for env_name, env_value in variables.items():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ style = "https://raw.githubusercontent.com/wemake-services/wemake-python-stylegu

[tool.poetry]
name = "dump-env"
version = "1.1.0"
version = "1.1.1"
description = "A utility tool to create .env files"

license = "MIT"
Expand Down
87 changes: 0 additions & 87 deletions tests/test_cli.py

This file was deleted.

48 changes: 48 additions & 0 deletions tests/test_cli/test_general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-

import delegator


def test_simple_usage(monkeypatch):
"""Check that cli shows prefixed variables."""
monkeypatch.setenv('SOM_TT_VALUE', '1')

variables = delegator.run('dump-env -p SOM_TT_')
assert variables.out == 'VALUE=1\n'


def test_both_options(monkeypatch, env_file):
"""
Check with template and prefix.
CLI must show all prefixed variables by template.
"""
monkeypatch.setenv('SOM_TT_VALUE', '1')

variables = delegator.run('dump-env -p SOM_TT_ -t {0}'.format(env_file))
assert variables.out == 'NORMAL_KEY=SOMEVALUE\nVALUE=1\n'


def test_multiple_prefixes(monkeypatch):
"""
Check that CLI with multiple prefixes.
CLI must show all prefixed variables correctly.
"""
monkeypatch.setenv('SOM_TT_VALUE', '1')
monkeypatch.setenv('ANOTHER_TT_VALUE', '2')

variables = delegator.run('dump-env -p SOM_TT_ -p ANOTHER_TT_')
assert variables.out == 'VALUE=2\n'


def test_simple_usage_file_output(monkeypatch, tmpdir):
"""Check that CLI puts prefixed variables into file correctly."""
monkeypatch.setenv('SOM_TT_VALUE', '1')

filename = tmpdir.mkdir('tests').join('.env').strpath

delegator.run('dump-env -p SOM_TT_ > {0}'.format(filename))

with open(filename) as env_file:
assert env_file.read() == 'VALUE=1\n'
13 changes: 13 additions & 0 deletions tests/test_cli/test_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-

import delegator


def test_help_option():
"""Check that cli shows help."""
variables = delegator.run('dump-env --help')
assert 'show this help message and exit' in variables.out
assert '--template TEMPLATE' in variables.out
assert '--prefix PREFIX' in variables.out
assert '--strict' in variables.out
assert variables.subprocess.returncode == 0
44 changes: 44 additions & 0 deletions tests/test_cli/test_strict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

import delegator


def test_strict_vars1(monkeypatch):
"""Check that cli works correctly with strict vars."""
monkeypatch.setenv('SOM_TT_VALUE', '1')
monkeypatch.setenv('SOM_TT_KEY', '2')

variables = delegator.run('dump-env -p SOM_TT_ --strict=SOM_TT_KEY')
assert variables.out == 'KEY=2\nVALUE=1\n'
assert variables.subprocess.returncode == 0


def test_strict_vars2(monkeypatch):
"""Check that cli works correctly with strict vars."""
monkeypatch.setenv('SOM_TT_VALUE', '1')
monkeypatch.setenv('SOM_TT_KEY', '2')

variables = delegator.run(
'dump-env -p SOM_TT_ --strict=SOM_TT_KEY --strict=SOM_TT_VALUE',
)
assert variables.out == 'KEY=2\nVALUE=1\n'
assert variables.subprocess.returncode == 0


def test_strict_missing_vars1(monkeypatch):
"""Check that cli raises errors for missing strict keys."""
variables = delegator.run('dump-env -p SOM_TT_ --strict=SOM_TT_KEY')
assert variables.out == ''
assert variables.err == 'Missing env vars: SOM_TT_KEY\n'
assert variables.subprocess.returncode == 1


def test_strict_missing_vars2(monkeypatch):
"""Check that cli raises errors for missing strict keys."""
variables = delegator.run(
'dump-env -p SOM_TT_ --strict=SOM_TT_KEY --strict=SOM_TT_VALUE',
)
assert variables.out == ''
assert 'SOM_TT_VALUE' in variables.err
assert 'SOM_TT_KEY' in variables.err
assert variables.subprocess.returncode == 1

0 comments on commit ff70118

Please sign in to comment.