Skip to content
Snippets Groups Projects
Commit b042d254 authored by Vermaat's avatar Vermaat
Browse files

Use temporary cache directory for unit tests.

parent 3a3ba660
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,9 @@ Automated deployment on a remote host ...@@ -53,7 +53,9 @@ Automated deployment on a remote host
For deploying Mutalyzer on a remote (production or testing) host, we recommend For deploying Mutalyzer on a remote (production or testing) host, we recommend
to automate the steps described below by using Fabric and the included to automate the steps described below by using Fabric and the included
fabfile. fabfile. You need Fabric installed on your local machine:
easy_install fabric
To do a deployment on a server with an existing configured Mutalyzer To do a deployment on a server with an existing configured Mutalyzer
installation: installation:
...@@ -122,10 +124,6 @@ to your likings. ...@@ -122,10 +124,6 @@ to your likings.
Test the installation Test the installation
--------------------- ---------------------
Note: This step is broken at the moment. Some tests write to the cache for
which we have no rights. This should be fixed to have a temporary cache
for the tests I guess.
You should always test the installation. The tests (for now at least) need You should always test the installation. The tests (for now at least) need
the batch daemon and the webserver (the SOAP part) running. the batch daemon and the webserver (the SOAP part) running.
......
...@@ -38,9 +38,10 @@ Development notes ...@@ -38,9 +38,10 @@ Development notes
Todo list: Todo list:
- Improve the web interface design :) - Improve the web interface design :)
- Tests fail in clean installation, because name checker tests make the - Running Mutalyzer as a local user (either bin/mutalyzer-website.wsgi on port
Retriever want to write to the cache and we don't run the tests as the 8080, or bin/mutalyzer for example) should be able with a partly different
user that owns the cache. How to fix this? configuration. Expecially cache and log file locations, because they are
owned by www-data.
- Test all uses of mkstemp(). - Test all uses of mkstemp().
- Use naming conventions for modules Crossmap, Db, File, GenRecord, Mapper, - Use naming conventions for modules Crossmap, Db, File, GenRecord, Mapper,
Retriever, Scheduler. Retriever, Scheduler.
...@@ -60,15 +61,16 @@ Todo list: ...@@ -60,15 +61,16 @@ Todo list:
obscures the control flow. The logging part should use the standard logging obscures the control flow. The logging part should use the standard logging
module. The data gathering by the Output object is probably better handled module. The data gathering by the Output object is probably better handled
by explicitely returning data objects from functions. by explicitely returning data objects from functions.
- Migrate from TAL to a more mondern and maintained Python template library. - Migrate from TAL to a more mondern and maintained Python template library,
for example jinja.
- Develop a large test suite. - Develop a large test suite.
- Create a web interface url to watch the progress of a batch job. - Create a web interface url to watch the progress of a batch job.
- Use virtualenv? - Use virtualenv?
- Use SQLAlchemy? - Use SQLAlchemy?
- Perhaps the WSGI interface should be somewhere else and be called
mutalyzer.wsgi?
- Password for MySQL user. - Password for MySQL user.
- In deployment, remove old versions of Mutalyzer package. - In deployment, remove old versions of Mutalyzer package?
- Use https protocol.
- Check for os.path.join vulnerabilities.
Code style guide: Code style guide:
- Follow PEP 8 (code) and PEP 257 (docstrings). - Follow PEP 8 (code) and PEP 257 (docstrings).
...@@ -109,18 +111,23 @@ Mutalyzer depends on the following (Debian/Ubuntu) packages: ...@@ -109,18 +111,23 @@ Mutalyzer depends on the following (Debian/Ubuntu) packages:
- python-biopython >= 1.54 - python-biopython >= 1.54
- python-pyparsing >= 1.5.0 - python-pyparsing >= 1.5.0
- python-configobj >= 4.4.0 - python-configobj >= 4.4.0
- python-simpletal >= 4.1-6
- python-soappy >= 0.12.0-2
- python-magic >= 5.04-2 - python-magic >= 5.04-2
- python-psutil >= 0.1.3-1 - python-psutil >= 0.1.3-1
- python-xlrd >= 0.6.1-2 - python-xlrd >= 0.6.1-2
- python-daemon >= 1.5.5 - python-daemon >= 1.5.5
- python-webpy >= 0.33 - python-soappy >= 0.12.0-2
- python-webtest >= 1.2.3
- python-suds >= 0.3.9-1 - python-suds >= 0.3.9-1
- python-nose >= 0.11
The web and SOAP interfaces depend on the following packages: The web and SOAP interfaces depend on the following packages:
- apache2 >= 2.2.11 - apache2 >= 2.2.11
- libapache2-mod-wsgi >= 2.8 - libapache2-mod-wsgi >= 2.8
- python-webpy >= 0.33
- python-soaplib >= 2.0.0-alpha1 - python-soaplib >= 2.0.0-alpha1
- python-simpletal >= 4.1-6
Automatic remote deployment depends on Fabric:
- fabric >= 0.9.0-2
The unit tests depend on the following packages:
- python-nose >= 0.11
- python-webtest >= 1.2.3
...@@ -46,8 +46,8 @@ class Config(): ...@@ -46,8 +46,8 @@ class Config():
each class is easy to see from the code below. each class is easy to see from the code below.
@kwarg filename: Optional filename to read configuration from. If @kwarg filename: Optional filename to read configuration from. If
present, this overrides automatic detection of present, this overrides automatic detection of configuration file
configuration file location. location.
@type filename: string @type filename: string
@raise ConfigurationError: If configuration could not be read. @raise ConfigurationError: If configuration could not be read.
...@@ -56,9 +56,11 @@ class Config(): ...@@ -56,9 +56,11 @@ class Config():
- Configuration file could not be parsed. - Configuration file could not be parsed.
- Not all variables are present in configuration file. - Not all variables are present in configuration file.
@todo: Store configuration filename in this object, so we can call @todo: Be able to have /etc/mutalyzer/config as 'base' configuration
executables (e.g. the batch checker) with as argument the and some additional configuration in ~/.mutalyzer/config to
current configuration filename. overwrite the base configuration.
For example, a normal user could use a different cache directory
(writable by the user) than the system wide Mutalyzer config.
""" """
if filename is None: if filename is None:
base = os.environ.get('XDG_CONFIG_HOME', None) base = os.environ.get('XDG_CONFIG_HOME', None)
...@@ -132,12 +134,18 @@ class Config(): ...@@ -132,12 +134,18 @@ class Config():
self.GenRecord.spliceWarn = int(config["spliceWarn"]) self.GenRecord.spliceWarn = int(config["spliceWarn"])
# If we are in a testing environment, use a temporary file for # If we are in a testing environment, use a temporary file for
# logging. # logging and a temporary directory for the cache.
# We don't remove these after the tests, since they might be
# useful for debugging.
if mutalyzer.is_test(): if mutalyzer.is_test():
handle, filename = tempfile.mkstemp(suffix='.log', handle, filename = tempfile.mkstemp(suffix='.log',
prefix='mutalyzer-tests-') prefix='mutalyzer-tests-')
os.close(handle) os.close(handle)
self.Output.log = filename self.Output.log = filename
dirname = tempfile.mkdtemp(suffix='.cache',
prefix='mutalyzer-tests-')
self.Retriever.cache = dirname
self.Scheduler.resultsDir = dirname
except KeyError as e: except KeyError as e:
raise ConfigurationError('Missing configuration value: %s' % e) raise ConfigurationError('Missing configuration value: %s' % e)
......
...@@ -500,15 +500,6 @@ facilisi.""" ...@@ -500,15 +500,6 @@ facilisi."""
assert_equal(r.content_type, 'text/plain') assert_equal(r.content_type, 'text/plain')
r.mustcontain('NM_003002.1:c.3_4insG') r.mustcontain('NM_003002.1:c.3_4insG')
def test_reference(self):
"""
Download a reference file.
"""
r = self.app.get('/Reference/AB026906.1.gb')
assert_equal(r.content_type, 'text/plain')
assert_equal(r.content_length, 26427)
r.mustcontain('ggaaaaagtc tctcaaaaaa cctgctttat')
def test_soap_documentation(self): def test_soap_documentation(self):
""" """
Test the SOAP documentation generated from the WSDL. Test the SOAP documentation generated from the WSDL.
...@@ -560,7 +551,8 @@ facilisi.""" ...@@ -560,7 +551,8 @@ facilisi."""
""" """
Test the genbank uploader. Test the genbank uploader.
@todo: Test if returned genomic reference can indeed be used now. @todo: Use another genbank file to get a UD number and check that
we can then check variants using that UD number.
""" """
test_genbank_file = os.path.join(os.path.split(mutalyzer.package_root())[0], 'tests/data/AB026906.1.gb') test_genbank_file = os.path.join(os.path.split(mutalyzer.package_root())[0], 'tests/data/AB026906.1.gb')
r = self.app.get('/upload') r = self.app.get('/upload')
...@@ -570,3 +562,28 @@ facilisi.""" ...@@ -570,3 +562,28 @@ facilisi."""
open(test_genbank_file, 'r').read())) open(test_genbank_file, 'r').read()))
r = form.submit() r = form.submit()
r.mustcontain('Your reference sequence was uploaded successfully.') r.mustcontain('Your reference sequence was uploaded successfully.')
print r.body
def test_reference(self):
"""
Test if reference files are cached.
@todo: This test doesn't work, since for every request a new
temporary cache directory is created by the webserver instance
and thus the cached file from request i cannot be re-used in
request i+1.
"""
return
r = self.app.get('/check')
form = r.forms[0]
form['mutationName'] = 'AB026906.1:c.274G>T'
r = form.submit()
r.mustcontain('0 Errors',
'1 Warning',
'Raw variant 1: substitution at 7872',
'<a href="#bottom" class="hornav">go to bottom</a>',
'<input value="AB026906.1:c.274G&gt;T" type="text" name="mutationName" style="width:100%">')
r = self.app.get('/Reference/AB026906.1.gb')
assert_equal(r.content_type, 'text/plain')
assert_equal(r.content_length, 26427)
r.mustcontain('ggaaaaagtc tctcaaaaaa cctgctttat')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment