From e660984015e1bc6d48e9ccee5fe59691c4acd911 Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Mon, 9 Nov 2020 17:22:27 +0300 Subject: add tests for geno_db_exists in marker_regression/run_mapping.py --- .../wqflask/marker_regression/test_run_mapping.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'wqflask/tests') diff --git a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py index 0a5bc565..61bc8a1d 100644 --- a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py @@ -1,7 +1,7 @@ import unittest from unittest import mock from wqflask.marker_regression.run_mapping import get_genofile_samplelist - +from wqflask.marker_regression.run_mapping import geno_db_exists class AttributeSetter: def __init__(self,obj): @@ -15,7 +15,7 @@ class MockDataSetGroup(AttributeSetter): 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.group=MockDataSetGroup({"genofile":"~/genofiles/g1_file","name":"GP1_"}) self.dataset=AttributeSetter({"group":self.group}) def tearDown(self): @@ -32,5 +32,21 @@ class TestRunMapping(unittest.TestCase): result_2=get_genofile_samplelist(self.dataset) self.assertEqual(result_2,[]) + @mock.patch("wqflask.marker_regression.run_mapping.data_set") + def test_geno_db_exists(self,mock_data_set): + # mock_data_set.create_dataset_side_effect=None + mock_data_set.create_dataset.side_effect=[AttributeSetter({}),Exception()] + results_no_error=geno_db_exists(self.dataset) + results_with_error=geno_db_exists(self.dataset) + + self.assertEqual(mock_data_set.create_dataset.call_count,2) + self.assertEqual(results_with_error,"False") + self.assertEqual(results_no_error,"True") + + + + + + -- cgit v1.2.3