diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b62dbd47965dc144231af40b3e3224f9ec99a11b..09c43ca83f87780f75fcbfc4874de742dcaab79e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -24,11 +24,11 @@ web service: Now run the tests with: - MUTALYZER_ENV=test nosetests -v + nosetests -v Or, if you are in a hurry, skip the long-running tests with: - MUTALYZER_ENV=test MUTALYZER_QUICK_TEST=1 nosetests -v + MUTALYZER_QUICK_TEST=1 nosetests -v Working with feature branches diff --git a/INSTALL.md b/INSTALL.md index 7edef864fd4b996103edd6ad34e48b910fc07272..a4f7c2ce10940b26506b735f30b1fd6a4eb8f2ea 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -131,7 +131,7 @@ the batch daemon and the webserver (the SOAP part) running. Now run the tests: - MUTALYZER_ENV=test nosetests + nosetests Upgrade Mutalyzer diff --git a/fabfile.py b/fabfile.py index fcbe006dec18eee7085a8722b0cca7d3959b5dc3..9f6f8542abffe9e9427c42b558ba622508fc2f25 100644 --- a/fabfile.py +++ b/fabfile.py @@ -70,7 +70,7 @@ def deploy(bootstrap='no'): sudo('bash extras/post-upgrade.sh') # Run unittests. - #run('MUTALYZER_ENV=test nosetests -v') + #run('nosetests -v') # Now that all is set up, delete the folder again. # (I don't like to 'sudo rm -Rf'.) diff --git a/mutalyzer/Scheduler.py b/mutalyzer/Scheduler.py index d82ba140416ba83be5887ed840cb6e0b98b5f142..39494f5b416355307f5347492455fb7933f504a8 100644 --- a/mutalyzer/Scheduler.py +++ b/mutalyzer/Scheduler.py @@ -91,14 +91,8 @@ class Scheduler() : @arg url: The url containing the results @type url: string """ - if mutalyzer.is_test(): - return - - # Note: The above check with mutalyzer.is_test is bogus, since during - # a normal unit test, the batch checker process is not started in the - # environment of the unit tests. - # As sort of a hack, we therefore check for the patented address - # 'test@test.test', used in the unit tests. + # Mail is set to 'test@test.test" if the batch job was submitted from + # a unit test. if mailTo == 'test@test.test': return diff --git a/mutalyzer/__init__.py b/mutalyzer/__init__.py index d087516efbf7d2492a0d6669e419d2d32a5bf582..13b87384e1477a19038daeed26019e66516f8fcc 100644 --- a/mutalyzer/__init__.py +++ b/mutalyzer/__init__.py @@ -3,9 +3,6 @@ HGVS variant nomenclature checker. """ -import os - - # On the event of a new release, we update the __version_info__ and __date__ # package globals and set RELEASE to True. # Before a release, a development version is denoted by a __version_info__ @@ -38,27 +35,3 @@ NOMENCLATURE_VERSION = '.'.join(NOMENCLATURE_VERSION_INFO) COPYRIGHT_YEARS = (2009, int(__date__[-4:])) SOAP_NAMESPACE = 'http://mutalyzer.nl/2.0/services' - - -def package_root(): - """ - Get the absolute path to the mutalyzer package. This is usefull for - things like locating HTML templates (which are in a subdirectory of the - package). - - @return: Absolute path to the mutalyzer package. - @rtype: string - """ - return os.path.realpath(os.path.split(__file__)[0]) - - -def is_test(): - """ - Check if we are in a test environment. This is determined by the - MUTALYZER_ENV environment variable, which should then be set to 'test'. - - @return: True if we are in a test environment, False otherwise. - @rtype: bool - """ - return 'MUTALYZER_ENV' in os.environ \ - and os.environ['MUTALYZER_ENV'] == 'test' diff --git a/mutalyzer/website.py b/mutalyzer/website.py index ed87d273169c06658d42e31ad1e88117a57056af..bb1787fe2c9022a57fa29a66e15dd4475da8383d 100644 --- a/mutalyzer/website.py +++ b/mutalyzer/website.py @@ -5,7 +5,6 @@ General Mutalyzer website interface. SERVICE_SOAP_LOCATION = '/services' SERVICE_JSON_LOCATION = '/json' -WSDL_VIEWER = 'templates/wsdl-viewer.xsl' GENOME_BROWSER_URL = 'http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&position={chromosome}:{start}-{stop}&hgt.customText={bed_file}' @@ -27,6 +26,7 @@ import urllib from collections import defaultdict from lxml import etree +import pkg_resources from cStringIO import StringIO from simpletal import simpleTALES from simpletal import simpleTAL @@ -176,7 +176,7 @@ class render_tal: # TAL template render -render = render_tal(os.path.join(mutalyzer.package_root(), 'templates'), +render = render_tal(pkg_resources.resource_filename('mutalyzer', 'templates'), globals = { 'version' : mutalyzer.__version__, 'nomenclatureVersion' : mutalyzer.NOMENCLATURE_VERSION, @@ -231,7 +231,9 @@ class Download: The url routing currently makes sure to only call this with filenames of the form [a-zA-Z-]+\.(?:py|cs). """ - file_path = os.path.join(mutalyzer.package_root(), 'templates', file) + file_path = os.path.join( + pkg_resources.resource_filename('mutalyzer', 'templates'), + file) if not os.path.isfile(file_path): raise web.notfound() @@ -263,8 +265,9 @@ class Downloads: The url routing currently makes sure to only call this with filenames of the form [a-zA-Z\._-]+. """ - file_path = os.path.join(mutalyzer.package_root(), 'templates', - 'downloads', file) + file_path = os.path.join( + pkg_resources.resource_filename('mutalyzer', 'templates'), + 'downloads', file) if not os.path.isfile(file_path): raise web.notfound() @@ -1541,8 +1544,9 @@ class SoapApi: wsdl = Wsdl11(soap.application.interface) wsdl.build_interface_document(url) wsdl_handle = StringIO(wsdl.get_interface_document()) - xsl_handle = open(os.path.join(mutalyzer.package_root(), WSDL_VIEWER), - 'r') + xsl_handle = open(os.path.join( + pkg_resources.resource_filename('mutalyzer', 'templates'), + 'wsdl-viewer.xsl'), 'r') wsdl_doc = etree.parse(wsdl_handle) xsl_doc = etree.parse(xsl_handle) transform = etree.XSLT(xsl_doc)