From 986b20363cc84be1822588dd7cc935fca7ef7f48 Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Mon, 9 Nov 2020 16:53:12 +0300 Subject: add test for get_genofile_samplelist in marker_regression/run_mapping.py --- .../wqflask/marker_regression/test_run_mapping.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 wqflask/tests/wqflask/marker_regression/test_run_mapping.py diff --git a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py new file mode 100644 index 00000000..0a5bc565 --- /dev/null +++ b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py @@ -0,0 +1,36 @@ +import unittest +from unittest import mock +from wqflask.marker_regression.run_mapping import get_genofile_samplelist + + +class AttributeSetter: + def __init__(self,obj): + for k,v in obj.items(): + setattr(self,k,v) + + +class MockDataSetGroup(AttributeSetter): + + def get_genofiles(self): + return [{"location":"~/genofiles/g1_file","sample_list":["S1","S2","S3","S4"]}] +class TestRunMapping(unittest.TestCase): + def setUp(self): + self.group=MockDataSetGroup({"genofile":"~/genofiles/g1_file"}) + self.dataset=AttributeSetter({"group":self.group}) + + def tearDown(self): + self.dataset=AttributeSetter({"group":{"location":"~/genofiles/g1_file"}}) + + + def test_get_genofile_samplelist(self): + #location true and sample list true + + results_1=get_genofile_samplelist(self.dataset) + self.assertEqual(results_1,["S1","S2","S3","S4"]) + #return empty array + self.group.genofile="~/genofiles/g2_file" + result_2=get_genofile_samplelist(self.dataset) + self.assertEqual(result_2,[]) + + + -- cgit v1.2.3