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

Links in standalone mode should retain this mode

Fixes #287
parent f3b05bc6
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,7 @@
<h4>Description relative to transcription start</h4>
<p>(Not for use in LSDBs in case of protein-coding transcripts).</p>
{% endif %}
<p><code><a href="{{ url_for('.name_checker', description=genomicDescription) }}">{{ genomicDescription }}</a></code></p>
<p><code><a href="{{ url_for('.name_checker', description=genomicDescription, standalone=standalone|int or None) }}">{{ genomicDescription }}</a></code></p>
{% endif %}
{% if chromDescription %}
......@@ -138,7 +138,7 @@
{% if i.endswith('?') %}
<p><code>{{ i }}</code></p>
{% else %}
<p><code><a href="{{ url_for('.name_checker', description=i) }}">{{ i }}</a></code></p>
<p><code><a href="{{ url_for('.name_checker', description=i, standalone=standalone|int or None) }}">{{ i }}</a></code></p>
{% endif %}
{% endfor %}
{% endif %}
......
......@@ -9,6 +9,8 @@ import bz2
from mock import patch
import os
from io import BytesIO
import re
import urlparse
from Bio import Entrez
import lxml.html
......@@ -24,6 +26,19 @@ from fixtures import with_references
# TODO: Tests for /upload.
def get_links(data, path=None):
"""
Extract all link targets, or only those targeting the specified path, from
the page and parse them.
"""
def parse_link(link):
splitted = urlparse.urlsplit(link)
return splitted.path, urlparse.parse_qs(splitted.query)
links = [parse_link(link) for link in re.findall('href="([^"]+)"', data)]
return [(p, q) for p, q in links if path is None or p == path]
@pytest.fixture
def website():
return create_app().test_client()
......@@ -301,6 +316,22 @@ def test_check_noninteractive(website):
assert 'Raw variant 1: deletion of 1' in r.data
@with_references('NG_012772.1')
def test_check_noninteractive_links(website):
"""
Submitting non-interactively should have links to transcripts also
non-interactive.
"""
r = website.get('/name-checker',
query_string={'description': 'NG_012772.1:g.128del',
'standalone': '1'})
assert '0 Errors' in r.data
links = get_links(r.data, path='/name-checker')
assert len(links) >= 2
assert all(q['standalone'] == ['1'] for _, q in links)
@with_references('NG_012772.1')
def test_check_interactive_links(website):
"""
......@@ -310,8 +341,10 @@ def test_check_interactive_links(website):
r = website.get('/name-checker',
query_string={'description': 'NG_012772.1:g.128del'})
assert '0 Errors' in r.data
assert 'href="/name-checker?description=NG_012772.1%3Ag.128del"' in r.data
assert 'href="/name-checker?description=NG_012772.1%28BRCA2_v001%29%3Ac.-5100del"' in r.data
links = get_links(r.data, path='/name-checker')
assert len(links) >= 2
assert all('standalone' not in q for _, q in links)
def test_snp_converter_valid(website):
......
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