mozilla/datazilla — pull request #31 by carljm (2012-06-04 16:05:48+00:00)
Title: Test setup

This branch contains a number of changes; the only thing they have in common is that I ran across all of them as dependencies for getting a reproducible isolated test suite in place (and related cleanups). Summarized:

1. Use Django's cache interface (an extremely light wrapper) rather than python-memcached directly. No actual API change, but it allows us to automatically prefix all memcached keys, which means that test runs can be sure they aren't reusing data from an existing memcached instance, necessary to ensure reproducible test runs.

2. Split the previously-massive `datazilla/model/models.py` into two files: the Django ORM stuff for loading datasets from the datasources table now goes in `datazilla/model/sql/models.py`, and the base `DatazillaModel` class goes in `datazilla/model/base.py` (though it's still imported in `__init__.py` so its import path `from datazilla.model import DatazillaModel` doesn't change).

3. Moved the transfer_data management command from `datazilla/model` to `datazilla/controller/admin`, since it seems to match the definition of the type of thing you'd originally intended to put in `datazilla/controller`.

4. Added SQLDataSource `create` and `create_next_dataset` methods which can create a new project (both the row in the datasource table and the new database itself, with empty schema) and create the next dataset in sequence for an existing project, respectively.

5. Created `pytest_sessionstart` and `pytest_sessionfinish` hook functions that set up and tear down the test environment, including a temporary test-only database.

Next up (in a different pull request) - adding pytest funcargs (test resources) for a full test-only project database, with isolation between tests, in order to allow the existing tests to pass again.