db_integration_test-1.1.0
توضیحات
Easily setup relational database fixtures and assert database contents in unittest.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | db_integration_test-1.1.0 |
| نام | db_integration_test |
| نسخه کتابخانه | 1.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Florian Plattner |
| ایمیل نویسنده | me@florianplattner.de |
| آدرس صفحه اصلی | https://github.com/flowpl/dbit |
| آدرس اینترنتی | https://pypi.org/project/db_integration_test/ |
| مجوز | MIT |
db_integration_test
===================
Easily setup relational database fixtures and assert database contents in unittest.
Install
-------
.. code-block:: bash
$ pip install db_integration_test
Usage
-----
.. code-block:: python
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'}])
نحوه نصب
نصب پکیج whl db_integration_test-1.1.0:
pip install db_integration_test-1.1.0.whl
نصب پکیج tar.gz db_integration_test-1.1.0:
pip install db_integration_test-1.1.0.tar.gz