aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/tests')
-rw-r--r--wqflask/tests/base/test_data_set.py69
-rw-r--r--wqflask/tests/base/test_general_object.py9
-rw-r--r--wqflask/tests/wqflask/api/test_gen_menu.py6
-rw-r--r--wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py91
4 files changed, 114 insertions, 61 deletions
diff --git a/wqflask/tests/base/test_data_set.py b/wqflask/tests/base/test_data_set.py
index dd7f5051..b1de4932 100644
--- a/wqflask/tests/base/test_data_set.py
+++ b/wqflask/tests/base/test_data_set.py
@@ -4,7 +4,7 @@ import unittest
import mock
from wqflask import app
-from data import gen_menu_json
+from .data import gen_menu_json
from base.data_set import DatasetType
@@ -59,9 +59,14 @@ class TestDataSetTypes(unittest.TestCase):
self.assertEqual(data_set("BXDGeno"), "Geno")
self.assertEqual(data_set("BXDPublish"), "Publish")
self.assertEqual(data_set("HLC_0311"), "ProbeSet")
+
redis_mock.set.assert_called_once_with(
"dataset_structure",
- '{"BXDGeno": "Geno", "BXDPublish": "Publish", "HLCPublish": "Publish", "HLC_0311": "ProbeSet", "HC_M2_0606_P": "ProbeSet"}')
+ ('{"HLC_0311": "ProbeSet", '
+ '"HLCPublish": "Publish", '
+ '"BXDGeno": "Geno", '
+ '"HC_M2_0606_P": "ProbeSet", '
+ '"BXDPublish": "Publish"}'))
@mock.patch('base.data_set.g')
def test_set_dataset_key_mrna(self, db_mock):
@@ -74,8 +79,17 @@ class TestDataSetTypes(unittest.TestCase):
self.assertEqual(data_set("Test"), "ProbeSet")
redis_mock.set.assert_called_once_with(
"dataset_structure",
- '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "ProbeSet", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
- expected_db_call = """"""
+ ('{"AD-cases-controls-MyersGeno": "Geno", '
+ '"AD-cases-controls-MyersPublish": "Publish", '
+ '"AKXDGeno": "Geno", '
+ '"AXBXAGeno": "Geno", '
+ '"AXBXAPublish": "Publish", '
+ '"Aging-Brain-UCIPublish": "Publish", '
+ '"All Phenotypes": "Publish", '
+ '"B139_K_1206_M": "ProbeSet", '
+ '"B139_K_1206_R": "ProbeSet", '
+ '"Test": "ProbeSet"}'))
+
db_mock.db.execute.assert_called_with(
("SELECT ProbeSetFreeze.Id FROM ProbeSetFreeze " +
"WHERE ProbeSetFreeze.Name = \"Test\" ")
@@ -92,12 +106,21 @@ class TestDataSetTypes(unittest.TestCase):
self.assertEqual(data_set("Test"), "Publish")
redis_mock.set.assert_called_once_with(
"dataset_structure",
- '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Publish", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+ ('{"AD-cases-controls-MyersGeno": "Geno", '
+ '"AD-cases-controls-MyersPublish": "Publish", '
+ '"AKXDGeno": "Geno", '
+ '"AXBXAGeno": "Geno", '
+ '"AXBXAPublish": "Publish", '
+ '"Aging-Brain-UCIPublish": "Publish", '
+ '"All Phenotypes": "Publish", '
+ '"B139_K_1206_M": "ProbeSet", '
+ '"B139_K_1206_R": "ProbeSet", '
+ '"Test": "Publish"}'))
db_mock.db.execute.assert_called_with(
- ("SELECT InfoFiles.GN_AccesionId " +
- "FROM InfoFiles, PublishFreeze, InbredSet " +
+ ("SELECT InfoFiles.GN_AccesionId "
+ "FROM InfoFiles, PublishFreeze, InbredSet "
"WHERE InbredSet.Name = 'Test' AND "
- "PublishFreeze.InbredSetId = InbredSet.Id AND " +
+ "PublishFreeze.InbredSetId = InbredSet.Id AND "
"InfoFiles.InfoPageName = PublishFreeze.Name")
)
@@ -110,9 +133,20 @@ class TestDataSetTypes(unittest.TestCase):
data_set = DatasetType(redis_mock)
data_set.set_dataset_key("other_pheno", "Test")
self.assertEqual(data_set("Test"), "Publish")
+
redis_mock.set.assert_called_once_with(
"dataset_structure",
- '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Publish", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
+ ('{"AD-cases-controls-MyersGeno": "Geno", '
+ '"AD-cases-controls-MyersPublish": "Publish", '
+ '"AKXDGeno": "Geno", '
+ '"AXBXAGeno": "Geno", '
+ '"AXBXAPublish": "Publish", '
+ '"Aging-Brain-UCIPublish": "Publish", '
+ '"All Phenotypes": "Publish", '
+ '"B139_K_1206_M": "ProbeSet", '
+ '"B139_K_1206_R": "ProbeSet", '
+ '"Test": "Publish"}'))
+
db_mock.db.execute.assert_called_with(
("SELECT PublishFreeze.Name " +
"FROM PublishFreeze, InbredSet " +
@@ -131,8 +165,17 @@ class TestDataSetTypes(unittest.TestCase):
self.assertEqual(data_set("Test"), "Geno")
redis_mock.set.assert_called_once_with(
"dataset_structure",
- '{"Aging-Brain-UCIPublish": "Publish", "AKXDGeno": "Geno", "B139_K_1206_M": "ProbeSet", "AD-cases-controls-MyersGeno": "Geno", "AD-cases-controls-MyersPublish": "Publish", "All Phenotypes": "Publish", "Test": "Geno", "AXBXAPublish": "Publish", "B139_K_1206_R": "ProbeSet", "AXBXAGeno": "Geno"}')
- expected_db_call = """"""
+ ('{"AD-cases-controls-MyersGeno": "Geno", '
+ '"AD-cases-controls-MyersPublish": "Publish", '
+ '"AKXDGeno": "Geno", '
+ '"AXBXAGeno": "Geno", '
+ '"AXBXAPublish": "Publish", '
+ '"Aging-Brain-UCIPublish": "Publish", '
+ '"All Phenotypes": "Publish", '
+ '"B139_K_1206_M": "ProbeSet", '
+ '"B139_K_1206_R": "ProbeSet", '
+ '"Test": "Geno"}'))
+
db_mock.db.execute.assert_called_with(
- ("SELECT GenoFreeze.Id FROM GenoFreeze WHERE GenoFreeze.Name = \"Test\" ")
- )
+ ("SELECT GenoFreeze.Id FROM "
+ "GenoFreeze WHERE GenoFreeze.Name = \"Test\" "))
diff --git a/wqflask/tests/base/test_general_object.py b/wqflask/tests/base/test_general_object.py
index c7701021..00fd3c72 100644
--- a/wqflask/tests/base/test_general_object.py
+++ b/wqflask/tests/base/test_general_object.py
@@ -17,9 +17,9 @@ class TestGeneralObjectTests(unittest.TestCase):
def test_object_dict(self):
"""Test whether the base class is printed properly"""
test_obj = GeneralObject("a", name="test", value=1)
- self.assertEqual(str(test_obj), "value = 1\nname = test\n")
+ self.assertEqual(str(test_obj), "name = test\nvalue = 1\n")
self.assertEqual(
- repr(test_obj), "value = 1\nname = test\ncontents = ['a']\n")
+ repr(test_obj), "contents = ['a']\nname = test\nvalue = 1\n")
self.assertEqual(len(test_obj), 2)
self.assertEqual(test_obj["value"], 1)
test_obj["test"] = 1
@@ -36,6 +36,5 @@ class TestGeneralObjectTests(unittest.TestCase):
test_obj1 = GeneralObject("a", name="test", value=1)
test_obj2 = GeneralObject("b", name="test2", value=2)
test_obj3 = GeneralObject("a", name="test", x=1, y=2)
- self.assertTrue(test_obj1 == test_obj2 )
- self.assertFalse(test_obj1 == test_obj3 )
-
+ self.assertTrue(test_obj1 == test_obj2)
+ self.assertFalse(test_obj1 == test_obj3)
diff --git a/wqflask/tests/wqflask/api/test_gen_menu.py b/wqflask/tests/wqflask/api/test_gen_menu.py
index 239484aa..bf41054d 100644
--- a/wqflask/tests/wqflask/api/test_gen_menu.py
+++ b/wqflask/tests/wqflask/api/test_gen_menu.py
@@ -2,6 +2,7 @@
import unittest
import mock
+from wqflask import app
from wqflask.api.gen_menu import gen_dropdown_json
from wqflask.api.gen_menu import get_species
from wqflask.api.gen_menu import get_groups
@@ -17,6 +18,8 @@ class TestGenMenu(unittest.TestCase):
"""Tests for the gen_menu module"""
def setUp(self):
+ self.app_context = app.app_context()
+ self.app_context.push()
self.test_group = {
'mouse': [
['H_T1',
@@ -67,6 +70,9 @@ class TestGenMenu(unittest.TestCase):
}
}
+ def tearDown(self):
+ self.app_context.pop()
+
@mock.patch('wqflask.api.gen_menu.g')
def test_get_species(self, db_mock):
"""Test that assertion is raised when dataset and dataset_name
diff --git a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py
index 6f791df1..8ae0f09f 100644
--- a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py
+++ b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py
@@ -1,6 +1,6 @@
import unittest
-from htmlgen import HTMLgen2 as HT
+import htmlgen as HT
from wqflask.marker_regression.display_mapping_results import (
DisplayMappingResults,
HtmlGenWrapper
@@ -26,9 +26,9 @@ class TestHtmlGenWrapper(unittest.TestCase):
width="10",
height="13",
usemap="#webqtlmap")),
- ("""<IMG src="test.png" height="13" width="10" """
- """alt="random" border="0" """
- """usemap="#webqtlmap">""")
+ ("""<img alt="random" border="0" height="13" """
+ """src="test.png" usemap="#webqtlmap" """
+ """width="10"/>""")
)
def test_create_form(self):
@@ -37,7 +37,7 @@ class TestHtmlGenWrapper(unittest.TestCase):
cgi="/testing/",
enctype='multipart/form-data',
name="formName",
- submit=HT.Input(type='hidden')
+ submit=HtmlGenWrapper.create_input_tag(type_='hidden', name='Default_Name')
)
test_image = HtmlGenWrapper.create_image_tag(
src="test.png",
@@ -49,10 +49,10 @@ class TestHtmlGenWrapper(unittest.TestCase):
)
self.assertEqual(
str(test_form).replace("\n", ""),
- ("""<FORM METHOD="POST" ACTION="/testing/" """
- """ENCTYPE="multipart/form-data" """
- """NAME="formName"><INPUT TYPE="hidden" """
- """NAME="Default_Name"></FORM>"""))
+ ("""<form action="/testing/" enctype="multipart/form-data" """
+ """method="POST" """
+ """name="formName"><input name="Default_Name" """
+ """type="hidden"/></form>"""))
hddn = {
'FormID': 'showDatabase',
'ProbeSetID': '_',
@@ -62,21 +62,26 @@ class TestHtmlGenWrapper(unittest.TestCase):
'incparentsf1': 'ON'
}
for key in hddn.keys():
- test_form.append(HT.Input(name=key, value=hddn[key],
- type='hidden'))
+ test_form.append(
+ HtmlGenWrapper.create_input_tag(
+ name=key,
+ value=hddn[key],
+ type_='hidden'))
test_form.append(test_image)
+
self.assertEqual(str(test_form).replace("\n", ""), (
- """<FORM METHOD="POST" ACTION="/testing/" """
- """ENCTYPE="multipart/form-data" NAME="formName">"""
- """<INPUT TYPE="hidden" NAME="database" VALUE="TestGeno">"""
- """<INPUT TYPE="hidden" NAME="incparentsf1" VALUE="ON">"""
- """<INPUT TYPE="hidden" NAME="FormID" VALUE="showDatabase">"""
- """<INPUT TYPE="hidden" NAME="ProbeSetID" VALUE="_">"""
- """<INPUT TYPE="hidden" NAME="RISet" VALUE="Test">"""
- """<INPUT TYPE="hidden" NAME="CellID" VALUE="_">"""
- """<IMG src="test.png" height="13" width="10" alt="random" """
- """border="0" usemap="#webqtlmap">"""
- """<INPUT TYPE="hidden" NAME="Default_Name"></FORM>"""))
+ """<form action="/testing/" enctype="multipart/form-data" """
+ """method="POST" name="formName">"""
+ """<input name="Default_Name" type="hidden"/>"""
+ """<input name="FormID" type="hidden" value="showDatabase"/>"""
+ """<input name="ProbeSetID" type="hidden" value="_"/>"""
+ """<input name="database" type="hidden" value="TestGeno"/>"""
+ """<input name="CellID" type="hidden" value="_"/>"""
+ """<input name="RISet" type="hidden" value="Test"/>"""
+ """<input name="incparentsf1" type="hidden" value="ON"/>"""
+ """<img alt="random" border="0" height="13" src="test.png" """
+ """usemap="#webqtlmap" width="10"/>"""
+ """</form>"""))
def test_create_paragraph(self):
"""Test HT.Paragraph method"""
@@ -89,48 +94,48 @@ class TestHtmlGenWrapper(unittest.TestCase):
)
self.assertEqual(
str(test_p_element),
- """<P id="smallSize"></P>"""
+ """<p id="smallSize"></p>"""
)
- test_p_element.append(HT.BR())
+ test_p_element.append(HtmlGenWrapper.create_br_tag())
test_p_element.append(par_text)
self.assertEqual(
str(test_p_element),
- """<P id="smallSize"><BR>{}</P>""".format(par_text)
+ """<p id="smallSize"><br/>{}</p>""".format(par_text)
)
def test_create_br_tag(self):
"""Test HT.BR() method"""
self.assertEqual(str(HtmlGenWrapper.create_br_tag()),
- "<BR>")
+ "<br/>")
def test_create_input_tag(self):
"""Test HT.Input method"""
self.assertEqual(
str(HtmlGenWrapper.create_input_tag(
- type="hidden",
+ type_="hidden",
name="name",
value="key",
Class="trait trait_")).replace("\n", ""),
- ("""<INPUT TYPE="hidden" NAME="name" """
- """class="trait trait_" VALUE="key">"""))
+ ("""<input class="trait trait_" name="name" """
+ """type="hidden" value="key"/>"""))
def test_create_map_tag(self):
"""Test HT.Map method"""
self.assertEqual(str(HtmlGenWrapper.create_map_tag(
name="WebqTLImageMap")).replace("\n", ""),
- """<MAP NAME="WebqTLImageMap"></MAP>""")
- gifmap = HtmlGenWrapper.create_map_tag(areas=[])
- gifmap.areas.append(HT.Area(shape="rect",
- coords='1 2 3', href='#area1'))
- gifmap.areas.append(HT.Area(shape="rect",
- coords='1 2 3', href='#area2'))
+ """<map name="WebqTLImageMap"></map>""")
+ gifmap = HtmlGenWrapper.create_map_tag(name="test")
+ gifmap.append(HtmlGenWrapper.create_area_tag(shape="rect",
+ coords='1 2 3', href='#area1'))
+ gifmap.append(HtmlGenWrapper.create_area_tag(shape="rect",
+ coords='1 2 3', href='#area2'))
self.assertEqual(
str(gifmap).replace("\n", ""),
- ("""<MAP NAME="">"""
- """<AREA coords="1 2 3" """
- """href="#area1" shape="rect">"""
- """<AREA coords="1 2 3" href="#area2" shape="rect">"""
- """</MAP>"""))
+ ("""<map name="test">"""
+ """<area coords="1 2 3" """
+ """href="#area1" shape="rect"/>"""
+ """<area coords="1 2 3" href="#area2" shape="rect"/>"""
+ """</map>"""))
def test_create_area_tag(self):
"""Test HT.Area method"""
@@ -140,12 +145,12 @@ class TestHtmlGenWrapper(unittest.TestCase):
coords="1 2",
href="http://test.com",
title="Some Title")).replace("\n", ""),
- ("""<AREA coords="1 2" href="http://test.com" """
- """shape="rect" title="Some Title">"""))
+ ("""<area coords="1 2" href="http://test.com" """
+ """shape="rect" title="Some Title"/>"""))
def test_create_link_tag(self):
"""Test HT.HREF method"""
self.assertEqual(
str(HtmlGenWrapper.create_link_tag(
"www.test.com", "test", target="_blank")).replace("\n", ""),
- """<A HREF="www.test.com" TARGET="_blank">test</A>""")
+ """<a href="www.test.com" target="_blank">test</a>""")