Add information about using file based sqlite for unit tests
This is helpful when you want to inspect the database when sitting at a break-point in a unit test. Change-Id: Id4e25ef980437fe160822c3598135aa220127ac8
This commit is contained in:
parent
ed58510023
commit
98838c491a
23
TESTING.rst
23
TESTING.rst
|
@ -121,6 +121,28 @@ its output. The test has many things going for it:
|
||||||
This is allowed by the fact that the method was built to be testable -
|
This is allowed by the fact that the method was built to be testable -
|
||||||
The method has clear input and output with no side effects.
|
The method has clear input and output with no side effects.
|
||||||
|
|
||||||
|
You can get oslo.db to generate a file-based sqlite database by setting
|
||||||
|
OS_TEST_DBAPI_ADMIN_CONNECTION to a file based URL as described in `this
|
||||||
|
mailing list post`__. This file will be created but (confusingly) won't be the
|
||||||
|
actual file used for the database. To find the actual file, set a break point
|
||||||
|
in your test method and inspect self.engine.url.
|
||||||
|
|
||||||
|
__ file-based-sqlite_
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ OS_TEST_DBAPI_ADMIN_CONNECTION=sqlite:///sqlite.db .tox/py27/bin/python -m \
|
||||||
|
testtools.run neutron.tests.unit...
|
||||||
|
...
|
||||||
|
(Pdb) self.engine.url
|
||||||
|
sqlite:////tmp/iwbgvhbshp.db
|
||||||
|
|
||||||
|
Now, you can inspect this file using sqlite3.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ sqlite3 /tmp/iwbgvhbshp.db
|
||||||
|
|
||||||
Functional Tests
|
Functional Tests
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -637,3 +659,4 @@ References
|
||||||
|
|
||||||
.. [#pudb] PUDB debugger:
|
.. [#pudb] PUDB debugger:
|
||||||
https://pypi.python.org/pypi/pudb
|
https://pypi.python.org/pypi/pudb
|
||||||
|
.. _file-based-sqlite: http://lists.openstack.org/pipermail/openstack-dev/2016-July/099861.html
|
||||||
|
|
Loading…
Reference in New Issue