Reference¶
Provides full reference to pytest-psqlgraph
Core Plugin¶
- pytest_psqlgraph.plugin.inject_driver_fixture(fixture: pytest_psqlgraph.helpers.DatabaseFixture, request: _pytest.fixtures.SubRequest) None [source]¶
Resolves and setups psqlgraph driver fixtures based on psqlgraph_config entries
- pytest_psqlgraph.plugin.inject_marker_data(mark: pytest_psqlgraph.models.PsqlgraphDataMark, item: _pytest.python.Function) None [source]¶
Resolves data for the custom psqlgraph data
Examples
@pytest.mark.psqlgraph_data( name="pg_data", driver_name="pg_driver", data_dir=here, resource="sample.yaml", post_processors=[append_mr], ) def test_example(pg_driver: psqlgraph.PsqlGraphDriver, pg_data: List[psqlgraph.Node]) -> None: ...
- pytest_psqlgraph.plugin.pytest_collection_finish(session: _pytest.main.Session) None [source]¶
A psqlgraph driver instance
Initializes the database tables and makes fixtures available .. rubric:: Example
code-block:
{"g": { "host": "localhost", "user": "test", "password": "test", "database": "test_db", "extra_bases": [], "models": model_module, "dictionary": dictionary instance } }
models¶
- class pytest_psqlgraph.models.DatabaseDriverConfig(host: str, user: str, password: str, database: str, model: pytest_psqlgraph.models.DataModel, dictionary: pytest_psqlgraph.models.Dictionary, package_namespace: Optional[str] = None, orm_base: Optional[sqlalchemy.ext.declarative.api.DeclarativeMeta] = None, extra_bases: Optional[Iterable[sqlalchemy.ext.declarative.api.DeclarativeMeta]] = None, globals: Optional[Dict[str, Any]] = None)[source]¶
Bases:
object
psqlgraph database configuration data
- host¶
postgres database hostname with port (if non default)
- Type
str
- user¶
postgres database username
- Type
str
- password¶
postgres database user password
- Type
str
- database¶
postgres database name to connect to
- Type
str
- package_namespace¶
optional parameter used to demarcate driver model classes
- Type
Optional[str]
- model¶
The python module containing all the models associated with this database
- dictionary¶
The instance containing the dictionary definitions
- orm_base¶
Optional sqlalchemy declarative base used by all models, this defaults to psqlgraph ORMBase
- Type
Optional[sqlalchemy.ext.declarative.api.DeclarativeMeta]
- extra_bases¶
Iterable of bases that needs to be created/destroyed as part of the driver
- Type
Optional[Iterable[sqlalchemy.ext.declarative.api.DeclarativeMeta]]
- globals¶
optional default property keys and values used for all nodes created
- Type
Optional[Dict[str, Any]]
- class pytest_psqlgraph.models.Dictionary(*args, **kwargs)[source]¶
Bases:
Protocol
A dictionary template
- schema¶
node name and schema pairs
- Type
Dict[str, psqlgml.types.DictionarySchemaDict]
- class pytest_psqlgraph.models.MarkExtension(g: psqlgraph.psql.PsqlGraphDriver)[source]¶
Bases:
object
An extension for psqlgraph data marker
- post(nodes: Iterable[psqlgraph.node.Node]) None [source]¶
Same as pre, but executes after data has been persisted
- Parameters
nodes – all nodes generated and persisted
helpers¶
Helper functions