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

Announcement in info webservice method

Closes #11
parent d7e5a404
No related branches found
No related tags found
No related merge requests found
......@@ -290,6 +290,8 @@ class InfoOutput(ComplexModel):
nomenclatureVersionParts = Array(String)
serverName = String
contactEmail = String
announcement = String
announcementUrl = String
#InfoOutput
......
......@@ -29,6 +29,7 @@ from mutalyzer.db.models import (Assembly, Chromosome, BatchJob,
from mutalyzer.output import Output
from mutalyzer.grammar import Grammar
from mutalyzer.sync import CacheSync
from mutalyzer import announce
from mutalyzer import stats
from mutalyzer import variantchecker
from mutalyzer.mapping import Converter
......@@ -1160,6 +1161,9 @@ class MutalyzerService(ServiceBase):
version as a list of strings.
- serverName: The name of the server that is being queried.
- contactEmail: The email address to contact for more information.
- announcement: Announcement body text.
- announcementUrl: URL to go with the announcement for further
information.
@rtype: object
"""
output = Output(__file__)
......@@ -1177,6 +1181,11 @@ class MutalyzerService(ServiceBase):
result.serverName = socket.gethostname()
result.contactEmail = mutalyzer.__contact__
announcement = announce.get_announcement()
if announcement:
result.announcement = announcement['body']
result.announcementUrl = announcement['url']
output.addMessage(__file__, -1, 'INFO', 'Finished processing info')
return result
#info
......
......@@ -6,6 +6,7 @@ Tests for the JSON interface to Mutalyzer.
import simplejson as json
from spyne.server.null import NullServer
import mutalyzer
from mutalyzer import announce
from mutalyzer.services.json import application
from fixtures import database, hg19, hg19_transcript_mappings
......@@ -78,3 +79,21 @@ class TestServicesJson(MutalyzerTest):
r = self._call('info')
assert type(r['versionParts']) == list
assert r['version'] == mutalyzer.__version__
def test_info_announcement(self):
"""
Running the info method should show us the current announcement
"""
announce.set_announcement('Test announcement')
r = self._call('info')
assert type(r['announcement']) == str
assert r['announcement'] == 'Test announcement'
announce.set_announcement('New announcement')
r = self._call('info')
assert type(r['announcement']) == str
assert r['announcement'] == 'New announcement'
announce.unset_announcement()
r = self._call('info')
assert not r.get('announcement')
......@@ -21,7 +21,7 @@ from Bio import Entrez
import lxml.html
import mutalyzer
from mutalyzer import Scheduler
from mutalyzer import announce, Scheduler
from mutalyzer.website import create_app
from fixtures import cache, database, hg19, hg19_transcript_mappings
......@@ -85,6 +85,25 @@ class TestWebsite(MutalyzerTest):
r = self.app.get(href)
assert r.status_code == 200
def test_announcement(self):
"""
We should always see the current announcement.
"""
announce.set_announcement('Test announcement')
r = self.app.get('/syntax-checker')
assert r.status == '200 OK'
assert 'Test announcement' in r.data
announce.set_announcement('New announcement')
r = self.app.get('/syntax-checker')
assert r.status == '200 OK'
assert 'New announcement' in r.data
announce.unset_announcement()
r = self.app.get('/syntax-checker')
assert r.status == '200 OK'
assert 'nnouncement' not in r.data
def test_description_extractor(self):
"""
Submit the variant description extractor.
......
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