db_integration_test
Easily setup relational database fixtures and assert database contents in unittest.
Install
$ pip install db_integration_test
Usage
from dbit import DatabaseTestCase, fixture
class SomeTest(DatabaseTestCase):
def setUp(self):
# the DB connection has to be created before the setUp is run.
# DatabaseTestCase only ever creates a single connection. Multiple calls to connect are ignored.
# to connect to a different DB, call self.disconnect(), then self.connect() with a different connection string.
# uses SQLAlchemy under the hood
self.connect('postgresql+psycopg2://user:pass@localhost/test_db')
super().setUp()
@fixture("table_name", [{'id': 1, 'value': 'abc'}, {'id': 2, 'value': 'def'}])
def test_something_with_your_database(self):
# interact with the DB
# self.engine contains the SQLAlchemy Engine
# self.session contains the SQLAlchemy ORM session
# self.base contains the automap base for the current database
# self.disconnect() disconnects from the DB
# assert that the table contents match the fixture exactly
self.assertMatchFixture("table_name", self.get_table_contents(self.base.classes.table_name))
# assert that some number of rows appear in the fixture
self.assertAllInFixture("table_name", [{'id': 1, 'value': 'abc'}])
Metadata
Release files for db_integration_test 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| db_integration_test-1.1.0.tar.gz | 5.3 kB | Without provenance | Details for db_integration_test-1.1.0.tar.gz |
Release files / db_integration_test-1.1.0.tar.gz
| Download URL | db_integration_test-1.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db90f127fd2eeb616271991d0b7c132177b73d713a546a0b24b27d51a67d32ee
|
|
BLAKE2b-256 checksum How to use checksums |
8f410717d6c8770c47e7754be6b0e297e3c8e453251fda6e9ffcb8ed44c78efb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for db_integration_test 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.