diff options
Diffstat (limited to 'wqflask/tests')
-rw-r--r-- | wqflask/tests/integration/__init__.py (renamed from wqflask/tests/base/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/integration/test_markdown_routes.py | 21 | ||||
-rw-r--r-- | wqflask/tests/unit/__init__.py (renamed from wqflask/tests/utility/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/__init__.py (renamed from wqflask/tests/wqflask/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/data.py (renamed from wqflask/tests/base/data.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/test_data_set.py (renamed from wqflask/tests/base/test_data_set.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/test_general_object.py (renamed from wqflask/tests/base/test_general_object.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/test_trait.py (renamed from wqflask/tests/base/test_trait.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/base/test_webqtl_case_data.py (renamed from wqflask/tests/base/test_webqtl_case_data.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/__init__.py (renamed from wqflask/tests/wqflask/api/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_authentication_tools.py (renamed from wqflask/tests/utility/test_authentication_tools.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_chunks.py (renamed from wqflask/tests/utility/test_chunks.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_corestats.py (renamed from wqflask/tests/utility/test_corestats.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_corr_result_helpers.py (renamed from wqflask/tests/utility/test_corr_result_helpers.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_formatting.py (renamed from wqflask/tests/utility/test_formatting.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/utility/test_hmac.py (renamed from wqflask/tests/utility/test_hmac.py) | 1 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/__init__.py (renamed from wqflask/tests/wqflask/marker_regression/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/api/__init__.py (renamed from wqflask/tests/wqflask/show_trait/__init__.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/api/test_gen_menu.py (renamed from wqflask/tests/wqflask/api/test_gen_menu.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/marker_regression/__init__.py | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/marker_regression/test_display_mapping_results.py (renamed from wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/show_trait/__init__.py | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/show_trait/test_export_trait_data.py (renamed from wqflask/tests/wqflask/show_trait/test_export_trait_data.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/test_collect.py (renamed from wqflask/tests/wqflask/test_collect.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/test_markdown_routes.py | 54 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/test_pbkdf2.py (renamed from wqflask/tests/wqflask/test_pbkdf2.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/test_user_login.py (renamed from wqflask/tests/wqflask/test_user_login.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/test_user_session.py (renamed from wqflask/tests/wqflask/test_user_session.py) | 0 | ||||
-rw-r--r-- | wqflask/tests/wqflask/show_trait/testSampleList.py | 16 | ||||
-rw-r--r-- | wqflask/tests/wqflask/show_trait/test_show_trait.py | 36 |
30 files changed, 127 insertions, 1 deletions
diff --git a/wqflask/tests/base/__init__.py b/wqflask/tests/integration/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/base/__init__.py +++ b/wqflask/tests/integration/__init__.py diff --git a/wqflask/tests/integration/test_markdown_routes.py b/wqflask/tests/integration/test_markdown_routes.py new file mode 100644 index 00000000..5e3e5045 --- /dev/null +++ b/wqflask/tests/integration/test_markdown_routes.py @@ -0,0 +1,21 @@ +"Integration tests for markdown routes" +import unittest + +from bs4 import BeautifulSoup + +from wqflask import app + + +class TestGenMenu(unittest.TestCase): + """Tests for glossary""" + + def setUp(self): + self.app = app.test_client() + + def tearDown(self): + pass + + def test_glossary_page(self): + """Test that the glossary page is rendered properly""" + response = self.app.get('/glossary', follow_redirects=True) + pass diff --git a/wqflask/tests/utility/__init__.py b/wqflask/tests/unit/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/utility/__init__.py +++ b/wqflask/tests/unit/__init__.py diff --git a/wqflask/tests/wqflask/__init__.py b/wqflask/tests/unit/base/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/wqflask/__init__.py +++ b/wqflask/tests/unit/base/__init__.py diff --git a/wqflask/tests/base/data.py b/wqflask/tests/unit/base/data.py index 06a5a989..06a5a989 100644 --- a/wqflask/tests/base/data.py +++ b/wqflask/tests/unit/base/data.py diff --git a/wqflask/tests/base/test_data_set.py b/wqflask/tests/unit/base/test_data_set.py index 96563a16..96563a16 100644 --- a/wqflask/tests/base/test_data_set.py +++ b/wqflask/tests/unit/base/test_data_set.py diff --git a/wqflask/tests/base/test_general_object.py b/wqflask/tests/unit/base/test_general_object.py index 00fd3c72..00fd3c72 100644 --- a/wqflask/tests/base/test_general_object.py +++ b/wqflask/tests/unit/base/test_general_object.py diff --git a/wqflask/tests/base/test_trait.py b/wqflask/tests/unit/base/test_trait.py index 826ccefd..826ccefd 100644 --- a/wqflask/tests/base/test_trait.py +++ b/wqflask/tests/unit/base/test_trait.py diff --git a/wqflask/tests/base/test_webqtl_case_data.py b/wqflask/tests/unit/base/test_webqtl_case_data.py index 8e8ba482..8e8ba482 100644 --- a/wqflask/tests/base/test_webqtl_case_data.py +++ b/wqflask/tests/unit/base/test_webqtl_case_data.py diff --git a/wqflask/tests/wqflask/api/__init__.py b/wqflask/tests/unit/utility/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/wqflask/api/__init__.py +++ b/wqflask/tests/unit/utility/__init__.py diff --git a/wqflask/tests/utility/test_authentication_tools.py b/wqflask/tests/unit/utility/test_authentication_tools.py index 5c391be5..5c391be5 100644 --- a/wqflask/tests/utility/test_authentication_tools.py +++ b/wqflask/tests/unit/utility/test_authentication_tools.py diff --git a/wqflask/tests/utility/test_chunks.py b/wqflask/tests/unit/utility/test_chunks.py index 8d90a1ec..8d90a1ec 100644 --- a/wqflask/tests/utility/test_chunks.py +++ b/wqflask/tests/unit/utility/test_chunks.py diff --git a/wqflask/tests/utility/test_corestats.py b/wqflask/tests/unit/utility/test_corestats.py index cf91a248..cf91a248 100644 --- a/wqflask/tests/utility/test_corestats.py +++ b/wqflask/tests/unit/utility/test_corestats.py diff --git a/wqflask/tests/utility/test_corr_result_helpers.py b/wqflask/tests/unit/utility/test_corr_result_helpers.py index e196fbdf..e196fbdf 100644 --- a/wqflask/tests/utility/test_corr_result_helpers.py +++ b/wqflask/tests/unit/utility/test_corr_result_helpers.py diff --git a/wqflask/tests/utility/test_formatting.py b/wqflask/tests/unit/utility/test_formatting.py index 9d3033d1..9d3033d1 100644 --- a/wqflask/tests/utility/test_formatting.py +++ b/wqflask/tests/unit/utility/test_formatting.py diff --git a/wqflask/tests/utility/test_hmac.py b/wqflask/tests/unit/utility/test_hmac.py index 4e3652f8..13d6261d 100644 --- a/wqflask/tests/utility/test_hmac.py +++ b/wqflask/tests/unit/utility/test_hmac.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Test hmac utility functions""" import unittest diff --git a/wqflask/tests/wqflask/marker_regression/__init__.py b/wqflask/tests/unit/wqflask/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/wqflask/marker_regression/__init__.py +++ b/wqflask/tests/unit/wqflask/__init__.py diff --git a/wqflask/tests/wqflask/show_trait/__init__.py b/wqflask/tests/unit/wqflask/api/__init__.py index e69de29b..e69de29b 100644 --- a/wqflask/tests/wqflask/show_trait/__init__.py +++ b/wqflask/tests/unit/wqflask/api/__init__.py diff --git a/wqflask/tests/wqflask/api/test_gen_menu.py b/wqflask/tests/unit/wqflask/api/test_gen_menu.py index 84898bd1..84898bd1 100644 --- a/wqflask/tests/wqflask/api/test_gen_menu.py +++ b/wqflask/tests/unit/wqflask/api/test_gen_menu.py diff --git a/wqflask/tests/unit/wqflask/marker_regression/__init__.py b/wqflask/tests/unit/wqflask/marker_regression/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/wqflask/tests/unit/wqflask/marker_regression/__init__.py diff --git a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py b/wqflask/tests/unit/wqflask/marker_regression/test_display_mapping_results.py index 8ae0f09f..8ae0f09f 100644 --- a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_display_mapping_results.py diff --git a/wqflask/tests/unit/wqflask/show_trait/__init__.py b/wqflask/tests/unit/wqflask/show_trait/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/wqflask/tests/unit/wqflask/show_trait/__init__.py diff --git a/wqflask/tests/wqflask/show_trait/test_export_trait_data.py b/wqflask/tests/unit/wqflask/show_trait/test_export_trait_data.py index 41761944..41761944 100644 --- a/wqflask/tests/wqflask/show_trait/test_export_trait_data.py +++ b/wqflask/tests/unit/wqflask/show_trait/test_export_trait_data.py diff --git a/wqflask/tests/wqflask/test_collect.py b/wqflask/tests/unit/wqflask/test_collect.py index 9a36132d..9a36132d 100644 --- a/wqflask/tests/wqflask/test_collect.py +++ b/wqflask/tests/unit/wqflask/test_collect.py diff --git a/wqflask/tests/unit/wqflask/test_markdown_routes.py b/wqflask/tests/unit/wqflask/test_markdown_routes.py new file mode 100644 index 00000000..90e0f17c --- /dev/null +++ b/wqflask/tests/unit/wqflask/test_markdown_routes.py @@ -0,0 +1,54 @@ +"""Test functions in markdown utils""" + +import unittest +from unittest import mock + +from dataclasses import dataclass +from wqflask.markdown_routes import render_markdown + + +@dataclass +class MockRequests404: + status_code: int = 404 + + +@dataclass +class MockRequests200: + status_code: int = 200 + content: str = b""" +# Glossary +This is some content + +## Sub-heading +This is another sub-heading""" + + +class TestMarkdownRoutesFunctions(unittest.TestCase): + """Test cases for functions in markdown_routes""" + + @mock.patch('wqflask.markdown_routes.requests.get') + def test_render_markdown_when_fetching_locally(self, requests_mock): + requests_mock.return_value = MockRequests404() + markdown_content = render_markdown("general/glossary/glossary.md") + requests_mock.assert_called_with( + "https://raw.githubusercontent.com" + "/genenetwork/gn-docs/" + "master/general/" + "glossary/glossary.md") + self.assertRegexpMatches(markdown_content, + "Content for general/glossary/glossary.md not available.") + + @mock.patch('wqflask.markdown_routes.requests.get') + def test_render_markdown_when_fetching_remotely(self, requests_mock): + requests_mock.return_value = MockRequests200() + markdown_content = render_markdown("general/glossary/glossary.md") + requests_mock.assert_called_with( + "https://raw.githubusercontent.com" + "/genenetwork/gn-docs/" + "master/general/" + "glossary/glossary.md") + self.assertEqual("""<h1>Glossary</h1> +<p>This is some content</p> +<h2>Sub-heading</h2> +<p>This is another sub-heading</p>""", + markdown_content) diff --git a/wqflask/tests/wqflask/test_pbkdf2.py b/wqflask/tests/unit/wqflask/test_pbkdf2.py index a33fbd4f..a33fbd4f 100644 --- a/wqflask/tests/wqflask/test_pbkdf2.py +++ b/wqflask/tests/unit/wqflask/test_pbkdf2.py diff --git a/wqflask/tests/wqflask/test_user_login.py b/wqflask/tests/unit/wqflask/test_user_login.py index 61cd9ab9..61cd9ab9 100644 --- a/wqflask/tests/wqflask/test_user_login.py +++ b/wqflask/tests/unit/wqflask/test_user_login.py diff --git a/wqflask/tests/wqflask/test_user_session.py b/wqflask/tests/unit/wqflask/test_user_session.py index ebb0334a..ebb0334a 100644 --- a/wqflask/tests/wqflask/test_user_session.py +++ b/wqflask/tests/unit/wqflask/test_user_session.py diff --git a/wqflask/tests/wqflask/show_trait/testSampleList.py b/wqflask/tests/wqflask/show_trait/testSampleList.py new file mode 100644 index 00000000..34c51e3e --- /dev/null +++ b/wqflask/tests/wqflask/show_trait/testSampleList.py @@ -0,0 +1,16 @@ +import unittest +import re +from unittest import mock +from wqflask.show_trait.SampleList import natural_sort + + +class TestSampleList(unittest.TestCase): + def test_natural_sort(self): + "Sort the list into natural alphanumeric order." + + characters_list = ["z", "f", "q", "s", "t", "a", "g"] + names_list = ["temp1", "publish", "Sample", "Dataset"] + sorted_list_a=natural_sort(characters_list) + sorted_list_b=natural_sort(names_list) + self.assertEqual(sorted_list_a, ["a", "f", "g", "q", "s", "t", "z"]) + self.assertEqual(sorted_list_b,["Dataset", "Sample", "publish", "temp1"]) diff --git a/wqflask/tests/wqflask/show_trait/test_show_trait.py b/wqflask/tests/wqflask/show_trait/test_show_trait.py index 24150738..8c866874 100644 --- a/wqflask/tests/wqflask/show_trait/test_show_trait.py +++ b/wqflask/tests/wqflask/show_trait/test_show_trait.py @@ -11,6 +11,7 @@ from wqflask.show_trait.show_trait import get_trait_units from wqflask.show_trait.show_trait import get_nearest_marker from wqflask.show_trait.show_trait import get_genotype_scales from wqflask.show_trait.show_trait import requests +from wqflask.show_trait.show_trait import get_scales_from_genofile class TraitObject: @@ -240,3 +241,38 @@ class TestTraits(unittest.TestCase): expected_results = {f"{file_location}": [["physic", "Mb"]]} self.assertEqual(get_genotype_scales(file_location), expected_results) mock_get_scales.assert_called_once_with(file_location) + + + @mock.patch("wqflask.show_trait.show_trait.locate_ignore_error") + def test_get_scales_from_genofile_found(self, mock_ignore_location): + """"add test for get scales from genofile where file is found""" + mock_ignore_location.return_value = True + geno_file = """ + #sample line with no @scales:other\n + #sample line @scales and :separated by semicolon\n + This attempts to check whether\n + """ + + geno_file_string = "@line start with @ and has @scale:morgan" + + file_location = "~/data/file.geno" + + mock_open_geno_file = mock.mock_open(read_data=geno_file) + with mock.patch("builtins.open", mock_open_geno_file): + results = get_scales_from_genofile(file_location) + self.assertEqual(results, [["morgan", "cM"]]) + + mock_open_string = mock.mock_open(read_data=geno_file_string) + + with mock.patch("builtins.open", mock_open_string): + result2 = get_scales_from_genofile(file_location) + self.assertEqual([['morgan', 'cM']], result2) + + @mock.patch("wqflask.show_trait.show_trait.locate_ignore_error") + def test_get_scales_from_genofile_not_found(self, mock_location_ignore): + mock_location_ignore.return_value = False + + expected_results = [["physic", "Mb"]] + results = get_scales_from_genofile("~/data/file") + mock_location_ignore.assert_called_once_with("~/data/file", "genotype") + self.assertEqual(results, expected_results) |