aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/tests/unit')
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py26
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py64
2 files changed, 45 insertions, 45 deletions
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
index 1198740d..47377873 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py
@@ -7,17 +7,17 @@ from wqflask.marker_regression.qtlreaper_mapping import gen_pheno_txt_file
class TestQtlReaperMapping(unittest.TestCase):
- @mock.patch("wqflask.marker_regression.qtlreaper_mapping.TEMPDIR", "/home/user/data")
- def test_gen_pheno_txt_file(self):
- vals = ["V1", "x", "V4", "V3","x"]
- samples = ["S1", "S2", "S3", "S4","S5"]
- trait_filename = "trait_file"
- with mock.patch("builtins.open", mock.mock_open())as mock_open:
- gen_pheno_txt_file(samples=samples, vals=vals,
- trait_filename=trait_filename)
- mock_open.assert_called_once_with("/home/user/data/gn2/trait_file.txt", "w")
- filehandler = mock_open()
- write_calls = [mock.call('Trait\t'), mock.call(
- 'S1\tS3\tS4\n'), mock.call('T1\t'), mock.call('V1\tV4\tV3')]
+ @mock.patch("wqflask.marker_regression.qtlreaper_mapping.TEMPDIR", "/home/user/data")
+ def test_gen_pheno_txt_file(self):
+ vals = ["V1", "x", "V4", "V3","x"]
+ samples = ["S1", "S2", "S3", "S4","S5"]
+ trait_filename = "trait_file"
+ with mock.patch("builtins.open", mock.mock_open())as mock_open:
+ gen_pheno_txt_file(samples=samples, vals=vals,
+ trait_filename=trait_filename)
+ mock_open.assert_called_once_with("/home/user/data/gn2/trait_file.txt", "w")
+ filehandler = mock_open()
+ write_calls = [mock.call('Trait\t'), mock.call(
+ 'S1\tS3\tS4\n'), mock.call('T1\t'), mock.call('V1\tV4\tV3')]
- filehandler.write.assert_has_calls(write_calls)
+ filehandler.write.assert_has_calls(write_calls)
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
index d69a20d3..e518ec22 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py
@@ -8,35 +8,35 @@ from wqflask.marker_regression.rqtl_mapping import sanitize_rqtl_names
class TestRqtlMapping(unittest.TestCase):
- def setUp(self):
- self.app_context = app.app_context()
- self.app_context.push()
-
- def tearDown(self):
- self.app_context.pop()
-
- @mock.patch("wqflask.marker_regression.rqtl_mapping.g")
- @mock.patch("wqflask.marker_regression.rqtl_mapping.logger")
- def test_get_trait_data(self, mock_logger, mock_db):
- """test for getting trait data_type return True"""
- query_value = """SELECT value FROM TraitMetadata WHERE type='trait_data_type'"""
- mock_db.db.execute.return_value.fetchone.return_value = [
- """{"type":"trait_data_type","name":"T1","traid_id":"fer434f"}"""]
- results = get_trait_data_type("traid_id")
- mock_db.db.execute.assert_called_with(query_value)
- self.assertEqual(results, "fer434f")
-
- def test_sanitize_rqtl_phenotype(self):
- """test for sanitizing rqtl phenotype"""
- vals = ['f', "x", "r", "x","x"]
- results = sanitize_rqtl_phenotype(vals)
- expected_phenotype_string = 'c(f,NA,r,NA,NA)'
-
- self.assertEqual(results, expected_phenotype_string)
-
- def test_sanitize_rqtl_names(self):
- """test for sanitzing rqtl names"""
- vals = ['f', "x", "r", "x","x"]
- expected_sanitized_name = "c('f',NA,'r',NA,NA)"
- results = sanitize_rqtl_names(vals)
- self.assertEqual(expected_sanitized_name, results)
+ def setUp(self):
+ self.app_context = app.app_context()
+ self.app_context.push()
+
+ def tearDown(self):
+ self.app_context.pop()
+
+ @mock.patch("wqflask.marker_regression.rqtl_mapping.g")
+ @mock.patch("wqflask.marker_regression.rqtl_mapping.logger")
+ def test_get_trait_data(self, mock_logger, mock_db):
+ """test for getting trait data_type return True"""
+ query_value = """SELECT value FROM TraitMetadata WHERE type='trait_data_type'"""
+ mock_db.db.execute.return_value.fetchone.return_value = [
+ """{"type":"trait_data_type","name":"T1","traid_id":"fer434f"}"""]
+ results = get_trait_data_type("traid_id")
+ mock_db.db.execute.assert_called_with(query_value)
+ self.assertEqual(results, "fer434f")
+
+ def test_sanitize_rqtl_phenotype(self):
+ """test for sanitizing rqtl phenotype"""
+ vals = ['f', "x", "r", "x","x"]
+ results = sanitize_rqtl_phenotype(vals)
+ expected_phenotype_string = 'c(f,NA,r,NA,NA)'
+
+ self.assertEqual(results, expected_phenotype_string)
+
+ def test_sanitize_rqtl_names(self):
+ """test for sanitzing rqtl names"""
+ vals = ['f', "x", "r", "x","x"]
+ expected_sanitized_name = "c('f',NA,'r',NA,NA)"
+ results = sanitize_rqtl_names(vals)
+ self.assertEqual(expected_sanitized_name, results)