Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from schireson/dc/extended-alembic-config
- Loading branch information
Showing
4 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from unittest import mock | ||
|
||
from pytest_alembic.config import Config | ||
|
||
|
||
def mock_open(*args, **kargs): | ||
f_open = mock.mock_open(*args, **kargs) | ||
f_open.return_value.__iter__ = lambda self: iter(self.readline, "") | ||
return f_open | ||
|
||
|
||
def test_default_file(): | ||
config = Config() | ||
|
||
with mock.patch("builtins.open", mock_open(read_data="[alembic]")): | ||
alembic_config = config.make_alembic_config(None) | ||
assert alembic_config.config_file_name == "alembic.ini" | ||
|
||
|
||
def test_set_file(): | ||
config = Config(config_options={"file": "foo.ini"}) | ||
|
||
with mock.patch("builtins.open", mock_open(read_data="[alembic]")): | ||
alembic_config = config.make_alembic_config(None) | ||
assert alembic_config.config_file_name == "foo.ini" | ||
|
||
|
||
def test_set_config_file_name(): | ||
config = Config(config_options={"config_file_name": "foo.ini"}) | ||
|
||
with mock.patch("builtins.open", mock_open(read_data="[alembic]")): | ||
alembic_config = config.make_alembic_config(None) | ||
assert alembic_config.config_file_name == "foo.ini" | ||
|
||
|
||
def test_set_sqlalchemy_url(): | ||
config = Config(config_options={"sqlalchemy.url": "sqlite:///"}) | ||
alembic_config = config.make_alembic_config(None) | ||
assert alembic_config.get_main_option("sqlalchemy.url") == "sqlite:///" | ||
|
||
|
||
def test_set_script_location(): | ||
config = Config(config_options={"script_location": "alembic"}) | ||
alembic_config = config.make_alembic_config(None) | ||
assert alembic_config.get_main_option("script_location") == "alembic" |