-
-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1372 from matthewhegarty/test-coverage-update
improve test coverage (#1372)
- Loading branch information
Showing
23 changed files
with
324 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Testing | ||
======= | ||
|
||
All tests can be run using `tox <https://tox.wiki/en/latest/>`_ simply by running the `tox` command. By default, tests are run against a local sqlite2 instance. | ||
|
||
MySql / Postgres tests | ||
###################### | ||
|
||
By using Docker, you can also run tests against either a MySQL db and/or Postgres. | ||
|
||
The ``IMPORT_EXPORT_TEST_TYPE`` must be set according to the type of tests you wish to run. Set to 'postgres' for postgres tests, and 'mysql-innodb' for mysql tests. If this environment variable is blank (or is any other value) then the default sqlite2 db will be used. | ||
|
||
This process is scripted in ``runtests.sh``. Assuming that you have docker installed on your system, running ``runtests.sh`` will run tox against sqlite2, mysql and postgres. You can edit this script to customise testing as you wish. | ||
|
||
Note that this is the process which is undertaken by CI builds. | ||
|
||
Coverage | ||
######## | ||
|
||
Coverage data is written in parallel mode by default (defined in ``setup.cfg``). After a tox run, you can view coverage data as follows: | ||
|
||
.. code-block:: bash | ||
# combine all coverage data generated by tox into one file | ||
coverage combine | ||
# produce an HTML coverage report | ||
coverage html | ||
Check the output of the above commands to locate the coverage HTML file. | ||
|
||
Bulk testing | ||
############ | ||
|
||
There is a helper script available to generate and profile bulk loads. See ``scripts/bulk_import.py``. | ||
|
||
You can use this script by configuring environment variables as defined above, and then installing and running the test application. In order to run the helper script, you will need to install ``requirements/test.txt``, and then add `django-extensions` to `settings.py` (`INSTALLED_APPS`). | ||
|
||
You can then run the script as follows: | ||
|
||
.. code-block:: bash | ||
# run creates, updates, and deletes | ||
./manage.py runscript bulk_import | ||
# pass 'create', 'update' or 'delete' to run the single test | ||
./manage.py runscript bulk_import --script-args create | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
isort | ||
psycopg2-binary | ||
mysqlclient | ||
coveralls | ||
chardet | ||
pytz | ||
memory-profiler | ||
django-extensions | ||
django-extensions | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
PYTHONPATH=".:tests:$PYTHONPATH" django-admin test core --settings=settings | ||
#!/usr/bin/env sh | ||
|
||
# run tests against all supported databases | ||
# postgres / mysql run via docker | ||
# sqlite (default) runs against local database file (database.db) | ||
|
||
echo "starting local database instances" | ||
docker-compose -f tests/docker-compose.yml up -d | ||
|
||
export DJANGO_SETTINGS_MODULE=settings | ||
|
||
export IMPORT_EXPORT_POSTGRESQL_USER=pguser | ||
export IMPORT_EXPORT_POSTGRESQL_PASSWORD=pguserpass | ||
|
||
export IMPORT_EXPORT_MYSQL_USER=mysqluser | ||
export IMPORT_EXPORT_MYSQL_PASSWORD=mysqluserpass | ||
|
||
echo "running tests (sqlite)" | ||
tox | ||
|
||
echo "running tests (mysql)" | ||
export IMPORT_EXPORT_TEST_TYPE=mysql-innodb | ||
tox | ||
|
||
echo "running tests (postgres)" | ||
export IMPORT_EXPORT_TEST_TYPE=postgres | ||
tox | ||
|
||
echo "removing local database instances" | ||
docker-compose -f tests/docker-compose.yml down -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.