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

Merge pull request #345 from mutalyzer/noninteractive-links

Links in standalone mode should retain this mode
parents f3b05bc6 15dcda64
No related branches found
No related tags found
No related merge requests found
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
<h4>Description relative to transcription start</h4> <h4>Description relative to transcription start</h4>
<p>(Not for use in LSDBs in case of protein-coding transcripts).</p> <p>(Not for use in LSDBs in case of protein-coding transcripts).</p>
{% endif %} {% 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 %} {% endif %}
{% if chromDescription %} {% if chromDescription %}
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
{% if i.endswith('?') %} {% if i.endswith('?') %}
<p><code>{{ i }}</code></p> <p><code>{{ i }}</code></p>
{% else %} {% 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 %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
......
...@@ -9,6 +9,8 @@ import bz2 ...@@ -9,6 +9,8 @@ import bz2
from mock import patch from mock import patch
import os import os
from io import BytesIO from io import BytesIO
import re
import urlparse
from Bio import Entrez from Bio import Entrez
import lxml.html import lxml.html
...@@ -24,6 +26,19 @@ from fixtures import with_references ...@@ -24,6 +26,19 @@ from fixtures import with_references
# TODO: Tests for /upload. # 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 @pytest.fixture
def website(): def website():
return create_app().test_client() return create_app().test_client()
...@@ -301,6 +316,22 @@ def test_check_noninteractive(website): ...@@ -301,6 +316,22 @@ def test_check_noninteractive(website):
assert 'Raw variant 1: deletion of 1' in r.data 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') @with_references('NG_012772.1')
def test_check_interactive_links(website): def test_check_interactive_links(website):
""" """
...@@ -310,8 +341,10 @@ def test_check_interactive_links(website): ...@@ -310,8 +341,10 @@ def test_check_interactive_links(website):
r = website.get('/name-checker', r = website.get('/name-checker',
query_string={'description': 'NG_012772.1:g.128del'}) query_string={'description': 'NG_012772.1:g.128del'})
assert '0 Errors' in r.data 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): 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