Permalink
Browse files

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
  • Loading branch information...
Carl Baldwin authored and ecbaldwin committed Jul 25, 2016
1 parent ed58510 commit 98838c491a5dc8c1d349a175401f80f2a912cc35
Showing with 23 additions and 0 deletions.
  1. +23 −0 TESTING.rst
View
@@ -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 -
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
~~~~~~~~~~~~~~~~
@@ -637,3 +659,4 @@ References
.. [#pudb] PUDB debugger:
https://pypi.python.org/pypi/pudb
.. _file-based-sqlite: http://lists.openstack.org/pipermail/openstack-dev/2016-July/099861.html

0 comments on commit 98838c4

Please sign in to comment.