Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
mutalyzer
Commits
3e6641f6
Commit
3e6641f6
authored
9 years ago
by
Vermaat
Browse files
Options
Downloads
Plain Diff
Merge pull request #67 from mutalyzer/tests-non-sqlite
Unit tests with PostgreSQL and MySQL
parents
a30a0d2f
1b141267
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.travis.yml
+8
-1
8 additions, 1 deletion
.travis.yml
doc/testing.rst
+18
-2
18 additions, 2 deletions
doc/testing.rst
mutalyzer/db/__init__.py
+1
-1
1 addition, 1 deletion
mutalyzer/db/__init__.py
tests/utils.py
+10
-1
10 additions, 1 deletion
tests/utils.py
with
37 additions
and
5 deletions
.travis.yml
+
8
−
1
View file @
3e6641f6
...
...
@@ -6,9 +6,16 @@ before_install:
-
sudo apt-get update -qq
-
sudo apt-get install -y swig
-
pip install -r requirements.txt
-
pip install psycopg2
install
:
-
pip install .
script
:
py.test
before_script
:
-
psql -c 'create database mutalyzer_test;' -U postgres
-
mysql -e 'create database mutalyzer_test;'
script
:
-
py.test
-
MUTALYZER_TEST_DATABASE_URI=postgres://postgres@127.0.0.1/mutalyzer_test py.test
-
MUTALYZER_TEST_DATABASE_URI=mysql://travis@127.0.0.1/mutalyzer_test?charset=utf8 py.test
notifications
:
slack
:
secure
:
"
VsB4CPZCfUPpnt7sL94mYrws2B9VthQhY1+u7NBm6QkAopel0m1rx1vWx3gQCTR0t9vWiP+pSybtQ81PQFNrOSWDsb1QlyEK1JF1QUw5Zui+5wS8fwFM/sgwGIECuo6Oj0zCwC9KMM4olYEMC2c7TNHv4HgwWiMqEK9ItEYSLQY="
This diff is collapsed.
Click to expand it.
doc/testing.rst
+
18
−
2
View file @
3e6641f6
...
...
@@ -15,9 +15,25 @@ the Mutalyzer source directory.
.. note:: The Mutalyzer package must be installed before running the unit
tests.
By default, the tests use an in-memory SQLite database. This can be customized
by setting the `MUTALYZER_TEST_DATABASE_URI` to a valid `SQLAlchemy connection
URI
<http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html#database-urls>`_
(obviously, the contents of this database will be lost). For example, to use
an SQLite database on the filesystem::
$ MUTALYZER_TEST_DATABASE_URI=sqlite:////tmp/mutalyzer.sql py.test
Or, using `pg_virtualenv
<https://alioth.debian.org/scm/loggerhead/pkg-postgresql/postgresql-common/trunk/view/head:/pg_virtualenv>`_
(included with the Debian PostgreSQL packages), to run the tests with
PostgreSQL::
$ pg_virtualenv bash -c 'MUTALYZER_TEST_DATABASE_URI=postgres://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT}/${PGDATABASE} py.test'
Tests are `run automatically on Travis CI
<https://travis-ci.org/LUMC/mutalyzer>`_
for each pull request and push on
GitHub.
<https://travis-ci.org/LUMC/mutalyzer>`_
with SQLite, PostgreSQL, and MySQL,
for each pull request and push on
GitHub.
Testing the web services
...
...
This diff is collapsed.
Click to expand it.
mutalyzer/db/__init__.py
+
1
−
1
View file @
3e6641f6
...
...
@@ -47,7 +47,7 @@ def create_engine():
engine
=
sqlalchemy
.
create_engine
(
url
,
**
options
)
# For convenience, we also create tables if we're using an SQLite
# in-memory database. By definition they won't yet exist
# in-memory database. By definition they won't yet exist
.
Base
.
metadata
.
create_all
(
engine
)
return
engine
...
...
This diff is collapsed.
Click to expand it.
tests/utils.py
+
10
−
1
View file @
3e6641f6
...
...
@@ -11,6 +11,7 @@ import shutil
import
tempfile
from
mutalyzer.config
import
settings
from
mutalyzer
import
db
class
TestEnvironment
(
object
):
...
...
@@ -25,13 +26,21 @@ class TestEnvironment(object):
log_handle
,
self
.
log_file
=
tempfile
.
mkstemp
()
os
.
close
(
log_handle
)
database_uri
=
os
.
getenv
(
'
MUTALYZER_TEST_DATABASE_URI
'
,
'
sqlite://
'
)
settings
.
configure
({
'
DEBUG
'
:
False
,
'
TESTING
'
:
True
,
'
CACHE_DIR
'
:
self
.
cache_dir
,
'
REDIS_URI
'
:
None
,
'
DATABASE_URI
'
:
'
sqlite://
'
,
'
DATABASE_URI
'
:
database_uri
,
'
LOG_FILE
'
:
self
.
log_file
})
# Mutalyzer create tables automatically if we're using an SQLite
# in-memory database.
if
database_uri
!=
'
sqlite://
'
:
db
.
Base
.
metadata
.
drop_all
(
db
.
session
.
get_bind
())
db
.
Base
.
metadata
.
create_all
(
db
.
session
.
get_bind
())
for
fixture
in
fixtures
:
fixture
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment