-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add configurable template option for postgres database creation.
- Loading branch information
Showing
3 changed files
with
44 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from sqlalchemy import Column, Integer | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
from pytest_mock_resources import create_postgres_fixture | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Thing(Base): | ||
__tablename__ = "thing" | ||
|
||
id = Column(Integer, autoincrement=True, primary_key=True) | ||
|
||
|
||
createdb_template_pg = create_postgres_fixture(Base, createdb_template="template0", session=True) | ||
|
||
|
||
def test_createdb_template(createdb_template_pg): | ||
"""Assert successful usage of a fixture which sets the `createdb_template` argument.""" | ||
thing = Thing(id=1) | ||
createdb_template_pg.add(thing) | ||
createdb_template_pg.commit() |