diff --git a/tests/test_services_json.py b/tests/test_services_json.py new file mode 100644 index 0000000000000000000000000000000000000000..6055a185aee5447062c14f7050b5f3ad907b4f76 --- /dev/null +++ b/tests/test_services_json.py @@ -0,0 +1,68 @@ +""" +Tests for the SOAP interface to Mutalyzer. +""" + + +from urllib import urlencode +import simplejson as json +import requests +from nose.tools import * +import mutalyzer + + +SERVICE_ROOT = 'http://localhost/mutalyzer/json/' + + +def call(method, **kwargs): + """ + Do a HTTP/RPC request and decode the JSON response. + """ + r = requests.get(SERVICE_ROOT + method + '?' + urlencode(kwargs)) + return json.loads(r.content) + + +class TestServicesJson(): + """ + Test the Mutalyzer HTTP/RPC+JSON interface. + """ + def test_checksyntax_valid(self): + """ + Running checkSyntax with a valid variant name should return True. + """ + r = call('checkSyntax', variant='AB026906.1:c.274G>T') + assert_equal(r['CheckSyntaxOutput']['valid'], True) + + def test_checksyntax_invalid(self): + """ + Running checkSyntax with an invalid variant name should return False + and give at least one error message. + """ + r = call('checkSyntax', variant='0:abcd') + assert_equal(r['CheckSyntaxOutput']['valid'], False) + assert len(r['CheckSyntaxOutput']['messages']['SoapMessage']) >= 1 + + def test_checksyntax_empty(self): + """ + Running checkSyntax with no variant name should raise exception. + """ + r = call('checkSyntax') + assert r['Fault'] + + def test_transcriptinfo_valid(self): + """ + Running transcriptInfo with valid arguments should get us a Transcript + object. + """ + r = call('transcriptInfo', LOVD_ver='123', build='hg19', + accNo='NM_002001.2') + assert_equal(r['Transcript']['trans_start'], -99) + assert_equal(r['Transcript']['trans_stop'], 1066) + assert_equal(r['Transcript']['CDS_stop'], 774) + + def test_info(self): + """ + Running the info method should give us some version information. + """ + r = call('info') + assert_equal(type(r['InfoOutput']['versionParts']['string']), list) + assert_equal(r['InfoOutput']['version'], mutalyzer.__version__) diff --git a/tests/test_webservice.py b/tests/test_services_soap.py similarity index 99% rename from tests/test_webservice.py rename to tests/test_services_soap.py index 8dabe7b35c0ff19c9da147674c56a33b2e242d69..0fdbec9a7be4227c6976adcd9ab0d6407d37a3b8 100644 --- a/tests/test_webservice.py +++ b/tests/test_services_soap.py @@ -46,11 +46,10 @@ class TestWSDL(): assert 'name="Mutalyzer"' in wsdl -class TestWebservice(): +class TestServicesSoap(): """ Test the Mutalyzer SOAP interface. """ - def setUp(self): """ Initialize webservice entrypoint.