From fd469a1029d0a44ff03743c535a5fdaaf6e3033a Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Thu, 21 Jul 2011 08:46:24 +0000
Subject: [PATCH] Fixes for failing unit tests (disabled temporary config
 values).

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/refactor-mutalyzer-branch@306 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
---
 mutalyzer/config.py   | 39 +++++++++++++++++++++++++++++++--------
 tests/test_website.py |  4 ++++
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/mutalyzer/config.py b/mutalyzer/config.py
index baa40b4f..339ec46e 100644
--- a/mutalyzer/config.py
+++ b/mutalyzer/config.py
@@ -138,14 +138,37 @@ class Config():
             # We don't remove these after the tests, since they might be
             # useful for debugging.
             if mutalyzer.is_test():
-                handle, filename = tempfile.mkstemp(suffix='.log',
-                                                    prefix='mutalyzer-tests-')
-                os.close(handle)
-                self.Output.log = filename
-                dirname = tempfile.mkdtemp(suffix='.cache',
-                                           prefix='mutalyzer-tests-')
-                self.Retriever.cache = dirname
-                self.Scheduler.resultsDir = dirname
+                # Todo:
+                #
+                # This needs some refactoring. The problem with the temporary
+                # file and dir names is that they will not be used by the
+                # (running) batch daemon, which will thus save its results to
+                # to 'normal' directory.
+                # Furthermore, subsequent web requests from a unit test will
+                # use different configuration instantiations, so might not
+                # see results from previous requests.
+                #
+                # We need a more robust solution for different configurations,
+                # depending of the running user/setting (e.g. unit tests).
+                #
+                # Idea: Don't create a local instance of the website in the
+                # unit tests, but only use running instances of all servers
+                # (website, webservice, batch daemon). They will use their
+                # own 'normal' configuration.
+                # All other parts of the unit tests will use temporary test
+                # configuration values. We might even decorate the tests
+                # needing server access as such and provide the option of
+                # skipping these.
+
+                #handle, filename = tempfile.mkstemp(suffix='.log',
+                #                                    prefix='mutalyzer-tests-')
+                #os.close(handle)
+                #self.Output.log = filename
+                #dirname = tempfile.mkdtemp(suffix='.cache',
+                #                           prefix='mutalyzer-tests-')
+                #self.Retriever.cache = dirname
+                #self.Scheduler.resultsDir = dirname
+                pass
 
         except KeyError as e:
             raise ConfigurationError('Missing configuration value: %s' % e)
diff --git a/tests/test_website.py b/tests/test_website.py
index ae3512be..e740edd4 100644
--- a/tests/test_website.py
+++ b/tests/test_website.py
@@ -15,6 +15,7 @@ I just installed webtest by 'easy_install webtest'.
 import os
 import re
 import time
+import web
 from nose.tools import *
 from webtest import TestApp
 
@@ -32,6 +33,7 @@ class TestWSGI():
         """
         Initialize test application.
         """
+        web.config.debug = False
         application = website.app.wsgifunc()
         self.app = TestApp(application)
 
@@ -448,6 +450,8 @@ facilisi."""
     def test_batch_multicolumn(self):
         """
         Submit the batch syntax checker with a multiple-colums input file.
+
+        This by the way also tests for the correct order of batch results.
         """
         variants = [('AB026906.1(SDHD):g.7872G>T', 'NM_003002.1:c.3_4insG'),
                     ('NM_003002.1:c.3_4insG', 'AB026906.1(SDHD):g.7872G>T'),
-- 
GitLab