Skip to content

Commit

Permalink
#90 fix CLI call with --config-file option
Browse files Browse the repository at this point in the history
  • Loading branch information
tbcvl committed Oct 29, 2020
1 parent 361864c commit c634e22
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions septentrion/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def parse_configuration_file(content: str) -> Dict:
a dict with values to use if they are
not overwritten in env vars or CLI flags
"""
if isinstance(content, bytes):
content = content.decode()
parser = configparser.ConfigParser()
parser.read_string(content)

Expand Down
16 changes: 16 additions & 0 deletions tests/acceptance/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pathlib

from septentrion import __main__, configuration
from septentrion import db as db_module

Expand Down Expand Up @@ -59,3 +61,17 @@ def test_current_database_state(cli_runner, db):
assert "Version 1.1" in result.output
assert "Applying 1.1-index-ddl.sql ..." in result.output
assert "Applied 1.1-index-ddl.sql" in result.output


def test_configuration_file_from_cli(cli_runner, temporary_directory, mocker):
mocker.patch("septentrion.core.describe_migration_plan")
mocker.patch("septentrion.db.create_table")
path = (
pathlib.Path(__file__).parent.parent.parent / "tests/test_data/config_file.ini"
)
result = cli_runner.invoke(
__main__.main,
[f"--config-file={path}", "show-migrations"],
catch_exceptions=False,
)
assert result.exit_code == 0, (result.output,)
9 changes: 9 additions & 0 deletions tests/test_data/config_file.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[septentrion]
schema_version=20.10
target_version=20.11
schema_template=schema_{}.sql
before_schema_file=
roles.sql
after_schema_file=
after_schemas.sql
fixtures_template=fixtures_{}.sql

0 comments on commit c634e22

Please sign in to comment.