Skip to content

Commit

Permalink
add proper readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Nov 30, 2016
1 parent 0c83665 commit 30141cf
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion README.rst
Expand Up @@ -32,7 +32,75 @@ Package status
:target: https://requires.io/github/ClearcodeHQ/pytest-redis/requirements/?tag=v0.0.0
:alt: Requirements Status

python package template - to make easier for me to duplicate general package structure.
What is this?
=============

This is a pytest plugin, that enables you to test your code that relies on a running Redis database.
It allows you to specify additional fixtures for Redis process and client.

How to use
==========

Plugin contains two fixtures

* **redis** - it's a client fixture that has functional scope. After each test, it cleans Redis database for more reliable tests.
* **redis_proc** - session scoped fixture, that starts Redis instance at it's first use and stops at the end of the tests.

Simply include one of these fixtures into your tests fixture list.

You can also create additional redis client and process fixtures if you'd need to:


.. code-block:: python
from pytest_redis import factories
redis_my_proc = factories.redis_proc(port=None, logsdir='/tmp')
redis_my = factories.redis('redis_my_proc')
.. note::

Each RabbitMQ process fixture can be configured in a different way than the others through the fixture factory arguments.

Configuration
=============

You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option.
You can pick which you prefer, but remember that these settings are handled in the following order:

* ``Fixture factory argument``
* ``Command line option``
* ``Configuration option in your pytest.ini file``

+------------------------+--------------------------+---------------------+-------------------+---------------------------------------+
| Redis option | Fixture factory argument | Command line option | pytest.ini option | Default |
+========================+==========================+=====================+===================+=======================================+
| Log directory location | logsdir | --redis-logsdir | redis_logsdir | $TMPDIR |
+------------------------+--------------------------+---------------------+-------------------+---------------------------------------+

Example usage:

* pass it as an argument in your own fixture

.. code-block:: python
redis_proc = factories.redis_proc(port=8888)
* use ``--redis-port`` command line option when you run your tests

.. code-block::
py.test tests --redis-port=8888
* specify your port as ``redis_port`` in your ``pytest.ini`` file.

To do so, put a line like the following under the ``[pytest]`` section of your ``pytest.ini``:

.. code-block:: ini
[pytest]
redis_port = 8888
Package resources
-----------------
Expand Down

0 comments on commit 30141cf

Please sign in to comment.