def test_load_wrong_format(self): p = param_to_json.HADDOCKParam() self.assertRaises(param_to_json.HADDOCKParamFormatError, p.load, "test/input/prot-prot-wrong.json") with tempfile.TemporaryFile() as fp: self.assertRaises(param_to_json.HADDOCKParamFormatError, p.load, fp)
def test_get_param(self): """Test HADDOCKParam get function with non-existing param""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") self.assertEqual(p.get("amb_cool1"), 10) self.assertEqual(p.get("centroid_kscale"), 50.0) self.assertEqual(p.get("clust_meth"), "FCC")
def test_haddockparam(self): """Test HADDOCKParam class""" p = param_to_json.HADDOCKParam() self.assertTrue(p.verbose) self.assertEqual(p.path, "") self.assertEqual(p.params, {}) self.assertFalse(p.valid)
def test_validate(self): p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") with self.assertLogs(level='WARNING') as cm: p.params['partners'].pop("2") p.validate() self.assertEqual(cm.output, ['WARNING:root:Only one partner defined']) self.assertEqual(p.nb_partners, 1) with self.assertLogs(level='WARNING') as cm: p.params['partners'].pop("1") p.validate() self.assertEqual(cm.output, ['WARNING:root:No partner defined']) self.assertEqual(p.nb_partners, 0)
def test_set_param(self): """Test HADDOCKParam set function""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") p.set("amb_cool1", 20.0) self.assertEqual(p.get("amb_cool1"), 20.0)
def test_set_wrong_param_format(self): """Test HADDOCKParam set function with wrong parameter format""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") self.assertRaises(param_to_json.HADDOCKParamFormatError, p.set, "amb_cool1", 20)
def test_set_wrong_param(self): """Test HADDOCKParam set function with non-existing param""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") self.assertRaises(param_to_json.HADDOCKParamError, p.set, "dummy_param", "dummy_value")
def test_get_wrong_param(self): """Test HADDOCKParam get function""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") self.assertRaises(param_to_json.HADDOCKParamError, p.get, "dummy_param")
def test_load(self): """Test parameter file loading""" p = param_to_json.HADDOCKParam() p.load("test/input/prot-prot-em.json") self.assertEqual(p.nb_partners, 2) self.assertTrue(p.valid)
def test_load_wrong_path(self): p = param_to_json.HADDOCKParam() self.assertRaises(FileNotFoundError, p.load, "dummy_path/dummy_file.json")