Skip to content
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 1 changed file with 23 additions and 0 deletions.
@@ -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 \ neutron.tests.unit...
(Pdb) self.engine.url
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:
.. _file-based-sqlite:

0 comments on commit 98838c4

Please sign in to comment.