From d8ba3a6fb10127506a3edd4b572797bb846da37c Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Sun, 23 Aug 2020 22:30:16 +0300 Subject: Fix failing test * wqflask/tests/wqflask/api/test_gen_menu.py: Update assertion. Result data introduced in 092212df Signed-off-by: BonfaceKilz --- wqflask/tests/wqflask/api/test_gen_menu.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'wqflask/tests') diff --git a/wqflask/tests/wqflask/api/test_gen_menu.py b/wqflask/tests/wqflask/api/test_gen_menu.py index 79c77fec..239484aa 100644 --- a/wqflask/tests/wqflask/api/test_gen_menu.py +++ b/wqflask/tests/wqflask/api/test_gen_menu.py @@ -255,9 +255,9 @@ class TestGenMenu(unittest.TestCase): ('Mouse Tissue'), ('Human Tissue'), ('Rat Tissue') ) self.assertEqual(build_types('mouse', 'random group'), - [['M', 'M', 'Molecular Trait Datasets'], - ['H', 'H', 'Molecular Trait Datasets'], - ['R', 'R', 'Molecular Trait Datasets']]) + [['M', 'M', 'Molecular Traits'], + ['H', 'H', 'Molecular Traits'], + ['R', 'R', 'Molecular Traits']]) db_mock.db.execute.assert_called_once_with( "SELECT DISTINCT Tissue.Name " + "FROM ProbeFreeze, ProbeSetFreeze, InbredSet, " + -- cgit v1.2.3 From cbc44ad7661b2da1bd434e186127fa8fab166a93 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Sun, 23 Aug 2020 23:53:37 +0300 Subject: Rename file * wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py: Rename test_display_marking_results.py to test_display_mapping_results.py --- .../wqflask/marker_regression/test_display_mapping_results.py | 9 +++++++++ .../wqflask/marker_regression/test_display_marking_results.py | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py delete mode 100644 wqflask/tests/wqflask/marker_regression/test_display_marking_results.py (limited to 'wqflask/tests') diff --git a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py new file mode 100644 index 00000000..67da508b --- /dev/null +++ b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py @@ -0,0 +1,9 @@ +import unittest + +from wqflask.marker_regression.display_mapping_results import DisplayMappingResults + +class TestDisplayMappingResults(unittest.TestCase): + def test_pil_colors(self): + """Test that colors use PILLOW color format""" + self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR, + (245, 211, 211)) diff --git a/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py b/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py deleted file mode 100644 index 67da508b..00000000 --- a/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py +++ /dev/null @@ -1,9 +0,0 @@ -import unittest - -from wqflask.marker_regression.display_mapping_results import DisplayMappingResults - -class TestDisplayMappingResults(unittest.TestCase): - def test_pil_colors(self): - """Test that colors use PILLOW color format""" - self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR, - (245, 211, 211)) -- cgit v1.2.3 From 7cafbbc2f13240c56ad31d47a7b429c9832c6df0 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 24 Aug 2020 18:11:11 +0300 Subject: Add tests for the HtmlGenWrapper class * wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py: Add new tests --- .../test_display_mapping_results.py | 144 ++++++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-) (limited to 'wqflask/tests') 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 67da508b..6f791df1 100644 --- a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py +++ b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py @@ -1,9 +1,151 @@ import unittest -from wqflask.marker_regression.display_mapping_results import DisplayMappingResults +from htmlgen import HTMLgen2 as HT +from wqflask.marker_regression.display_mapping_results import ( + DisplayMappingResults, + HtmlGenWrapper +) + class TestDisplayMappingResults(unittest.TestCase): + """Basic Methods to test Mapping Results""" def test_pil_colors(self): """Test that colors use PILLOW color format""" self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR, (245, 211, 211)) + + +class TestHtmlGenWrapper(unittest.TestCase): + """Test Wrapper around HTMLGen""" + def test_create_image(self): + """Test HT.Image method""" + self.assertEqual( + str(HtmlGenWrapper.create_image_tag(src="test.png", + alt="random", + border="0", + width="10", + height="13", + usemap="#webqtlmap")), + ("""""") + ) + + def test_create_form(self): + """Test HT.Form method""" + test_form = HtmlGenWrapper.create_form_tag( + cgi="/testing/", + enctype='multipart/form-data', + name="formName", + submit=HT.Input(type='hidden') + ) + test_image = HtmlGenWrapper.create_image_tag( + src="test.png", + alt="random", + border="0", + width="10", + height="13", + usemap="#webqtlmap" + ) + self.assertEqual( + str(test_form).replace("\n", ""), + ("""
""")) + hddn = { + 'FormID': 'showDatabase', + 'ProbeSetID': '_', + 'database': "TestGeno", + 'CellID': '_', + 'RISet': "Test", + 'incparentsf1': 'ON' + } + for key in hddn.keys(): + test_form.append(HT.Input(name=key, value=hddn[key], + type='hidden')) + test_form.append(test_image) + self.assertEqual(str(test_form).replace("\n", ""), ( + """
""" + """""" + """""" + """""" + """""" + """""" + """""" + """random""" + """
""")) + + def test_create_paragraph(self): + """Test HT.Paragraph method""" + test_p_element = HtmlGenWrapper.create_p_tag(id="smallSize") + par_text = ( + "Mapping using genotype data as " + "a trait will result in infinity LRS at one locus. " + "In order to display the result properly, all LRSs " + "higher than 100 are capped at 100." + ) + self.assertEqual( + str(test_p_element), + """

""" + ) + test_p_element.append(HT.BR()) + test_p_element.append(par_text) + self.assertEqual( + str(test_p_element), + """


{}

""".format(par_text) + ) + + def test_create_br_tag(self): + """Test HT.BR() method""" + self.assertEqual(str(HtmlGenWrapper.create_br_tag()), + "
") + + def test_create_input_tag(self): + """Test HT.Input method""" + self.assertEqual( + str(HtmlGenWrapper.create_input_tag( + type="hidden", + name="name", + value="key", + Class="trait trait_")).replace("\n", ""), + ("""""")) + + def test_create_map_tag(self): + """Test HT.Map method""" + self.assertEqual(str(HtmlGenWrapper.create_map_tag( + name="WebqTLImageMap")).replace("\n", ""), + """""") + 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')) + self.assertEqual( + str(gifmap).replace("\n", ""), + ("""""" + """""" + """""" + """""")) + + def test_create_area_tag(self): + """Test HT.Area method""" + self.assertEqual( + str(HtmlGenWrapper.create_area_tag( + shape="rect", + coords="1 2", + href="http://test.com", + title="Some Title")).replace("\n", ""), + ("""""")) + + 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", ""), + """test""") -- cgit v1.2.3