diff options
author | zsloan | 2021-05-27 20:18:36 +0000 |
---|---|---|
committer | zsloan | 2021-05-27 20:18:36 +0000 |
commit | 2c2e1dc3d4be635dbf73aab380e22acca6a2014b (patch) | |
tree | a3456bdd61648b538ab25f393272bfcb2a3dfc30 | |
parent | 6a54fa84542458fe8cfd288bf4c507214a1ddd04 (diff) | |
download | genenetwork2-2c2e1dc3d4be635dbf73aab380e22acca6a2014b.tar.gz |
Improved test_rqtl_mapping.py with Bonface's recommendation of uses dataclasses
-rw-r--r-- | wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py | 23 |
1 files changed, 10 insertions, 13 deletions
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 6853c021..bd97b2d2 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py @@ -2,17 +2,17 @@ import unittest from unittest import mock from wqflask.marker_regression.rqtl_mapping import run_rqtl -class AttributeSetter: - def __init__(self, obj): - for key, val in obj.items(): - setattr(self, key, val) +@dataclass +class MockGroup: + name: str, + genofile: str -class MockGroup(AttributeSetter): - def get_samplelist(self): - return None +@dataclass +class MockDataset: + group: MockGroup class TestRqtlMapping(unittest.TestCase): - + """Tests for functions in rqtl_mapping.py""" @mock.patch("wqflask.marker_regression.rqtl_mapping.process_rqtl_results") @mock.patch("wqflask.marker_regression.rqtl_mapping.process_perm_results") @mock.patch("wqflask.marker_regression.rqtl_mapping.requests.post") @@ -22,15 +22,12 @@ class TestRqtlMapping(unittest.TestCase): """Test for run_rqtl with permutations > 0""" dataset_group = MockGroup( {"name": "GP1", "genofile": "file_geno"}) - - dataset = AttributeSetter({"group": dataset_group}) + dataset = MockDataset(dataset_group) mock_write_pheno_file.return_value = "pheno_filename" mock_locate.return_value = "geno_filename" - mock_post.return_value = {"output_file": "output_filename", "rqtl_cmd": "the_command"} - mock_process_perm.return_value = [[], 3, 4] mock_process_rqtl.return_value = [] @@ -44,4 +41,4 @@ class TestRqtlMapping(unittest.TestCase): mock_post.assert_called_once() mock_process_perm.assert_called_once() mock_process_rqtl.assert_called_once() - self.assertEqual(results, ([], 3, 4, []))
\ No newline at end of file + self.assertEqual(results, ([], 3, 4, [])) |