def test_save_file_existing(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) dcfile.set_parm_value("side", "1") dcfile.set_parm_value("test2desc", "test2val", "test2comment") dcfile.save_file() newfile = dac_file.DACFile() newfile.parse_file(self.bc1_filename) self.assertEqual(newfile.get_parm_value("side"), "1") self.assertEqual(newfile.get_parm_value("test2desc"), "test2val") self.assertEqual(newfile.get_parm_comment("test2desc"), "test2comment")
def test_save_file_new(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) dcfile.set_parm_value("side", "1") dcfile.set_parm_value("test2desc", "test2val", "test2comment") dcfile.save_file("test2file") newfile = dac_file.DACFile() newfile.parse_file("test2file") self.assertEqual(newfile.get_parm_value("side"), "1") self.assertEqual(newfile.get_parm_value("test2desc"), "test2val") self.assertEqual(newfile.get_parm_comment("test2desc"), "test2comment") if os.path.exists("test2file"): os.remove("test2file")
def test_set_parm_value_new(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) dcfile.set_parm_value("test1desc", "test1val", "test1comment") self.assertEqual(dcfile.get_parm_value("test1desc"), "test1val") self.assertEqual(dcfile.get_parm_comment("test1desc"), "test1comment")
def test_set_parm_value_existing(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) comment = dcfile.get_parm_comment("side") dcfile.set_parm_value("side", "1") self.assertEqual(dcfile.get_parm_value("side"), "1") self.assertEqual(dcfile.get_parm_comment("side"), comment)
def test_bad_file(self): '''test case''' dcfile = dac_file.DACFile() with self.assertRaises(IOError): dcfile.parse_file("./badfile")
def test_bad_parm(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) self.assertEqual(dcfile.get_parm_value("mtnumber"), "")
def test_line_1_token(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) self.assertEqual(dcfile.get_parm_value("DIMC cldfile(9)"), "")
def test_line_2_tokens(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) self.assertEqual(dcfile.get_parm_value("mtnum"), "50")
def test_line_3_tokens(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc2_filename) self.assertEqual(dcfile.get_parm_value("side"), "2")
def test_is_bc_type_3(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.fc_filename) self.assertEqual(dcfile.is_bc_type(), False)
def test_is_bc_type_2(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc2_filename) self.assertEqual(dcfile.is_bc_type(), True)
def test_get_float_value(self): '''test case''' dcfile = dac_file.DACFile() dcfile.parse_file(self.bc1_filename) self.assertEqual(dcfile.get_float_value("data(27)"), 10.39565555)