From 149542045e0baedde9781cdd78dfba64920bb23f Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 27 Sep 2022 11:01:49 +0300 Subject: Unit Test: Fix unit test for Chromosome functions. --- wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py | 2 +- wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py index 24400b33..0d1bafc3 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py @@ -54,7 +54,7 @@ class TestGemmaMapping(unittest.TestCase): this_chromosomes = {} for i in range(1, 5): this_chromosomes[f'CH{i}'] = (AttributeSetter({"name": f"CH{i}"})) - chromosomes = AttributeSetter({"chromosomes": this_chromosomes}) + chromosomes = AttributeSetter({"chromosomes": lambda cursor: this_chromosomes}) dataset_group = MockGroup( {"name": "GP1", "genofile": "file_geno"}) diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py index 868b0b0b..2e1b5810 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py @@ -45,7 +45,7 @@ class TestRunMapping(unittest.TestCase): self.dataset = AttributeSetter( {"fullname": "dataset_1", "group": self.group, "type": "ProbeSet"}) - self.chromosomes = AttributeSetter({"chromosomes": chromosomes}) + self.chromosomes = AttributeSetter({"chromosomes": lambda cur: chromosomes}) self.trait = AttributeSetter( {"symbol": "IGFI", "chr": "X1", "mb": 123313, "display_name": "Test Name"}) @@ -251,12 +251,13 @@ class TestRunMapping(unittest.TestCase): def test_get_chr_length(self): """test for getting chromosome length""" + cursor = mock.MagicMock() chromosomes = AttributeSetter({"chromosomes": self.chromosomes}) dataset = AttributeSetter({"species": chromosomes}) results = get_chr_lengths( mapping_scale="physic", mapping_method="reaper", dataset=dataset, qtl_results=[]) chr_lengths = [] - for key, chromo in self.chromosomes.chromosomes.items(): + for key, chromo in self.chromosomes.chromosomes(cursor).items(): chr_lengths.append({"chr": chromo.name, "size": chromo.length}) self.assertEqual(chr_lengths, results) -- cgit v1.2.3