-
Notifications
You must be signed in to change notification settings - Fork 2
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 #57 from peopledoc/after-before-schema-files
Add feature to run schema files after main schema file too
- Loading branch information
Showing
11 changed files
with
193 additions
and
13 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ How-to... | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
howto/placeholder | ||
howto/configure | ||
howto/file_naming |
Empty file.
Empty file.
Empty file.
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,83 @@ | ||
import pathlib | ||
from unittest.mock import call | ||
|
||
from septentrion import configuration, versions | ||
from septentrion.core import get_best_schema_version | ||
from septentrion.migrate import init_schema | ||
|
||
|
||
def test_init_schema(mocker): | ||
patch = mocker.patch("septentrion.migrate.run_script",) | ||
|
||
settings = configuration.Settings.from_cli( | ||
{ | ||
"host": "", | ||
"port": "", | ||
"username": "", | ||
"dbname": "", | ||
"migrations_root": "example_migrations", | ||
"target_version": versions.Version.from_string("1.1"), | ||
} | ||
) | ||
|
||
init_schema( | ||
settings=settings, init_version=get_best_schema_version(settings=settings) | ||
) | ||
|
||
calls = [ | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/schemas/schema_0.1.sql"), | ||
), | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/fixtures/fixtures_0.1.sql"), | ||
), | ||
] | ||
assert calls == patch.call_args_list | ||
|
||
|
||
def test_init_schema_extra_files(mocker): | ||
patch = mocker.patch("septentrion.migrate.run_script",) | ||
|
||
settings = configuration.Settings.from_cli( | ||
{ | ||
"host": "", | ||
"port": "", | ||
"username": "", | ||
"dbname": "", | ||
"migrations_root": "example_migrations", | ||
"additional_schema_file": ["extra_file.sql"], | ||
"before_schema_file": ["before_file.sql"], | ||
"after_schema_file": ["after_file.sql"], | ||
"target_version": versions.Version.from_string("1.1"), | ||
} | ||
) | ||
|
||
init_schema( | ||
settings=settings, init_version=get_best_schema_version(settings=settings) | ||
) | ||
|
||
calls = [ | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/schemas/before_file.sql"), | ||
), | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/schemas/extra_file.sql"), | ||
), | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/schemas/schema_0.1.sql"), | ||
), | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/schemas/after_file.sql"), | ||
), | ||
call( | ||
settings=settings, | ||
path=pathlib.Path("example_migrations/fixtures/fixtures_0.1.sql"), | ||
), | ||
] | ||
assert calls == patch.call_args_list |
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