def test_rename_connection(self): filename = os.path.join(self.data_dir, "test_1.mo") new_filename = os.path.join(self.output_dir, "test_1_output_7.mo") f1 = InputParser(filename) # connect(weaDat.weaBus, HDifTil[3].weaBus) f1.replace_connect_string( "eqAirTemp.TEqAir", "prescribedTemperature.T", "NothingOfImportance", None ) f1.replace_connect_string("weaDat.weaBus", None, "weaBus", None, True) f1.save_as(new_filename) f2 = InputParser(new_filename) self.assertFalse(filecmp.cmp(filename, new_filename)) index, c = f2.find_connect('weaBus', 'weaBus') # there should exist the new connection self.assertGreaterEqual(index, 0) # the old one should not exist index, c = f2.find_connect('weaDat.weaBus', 'weaBus') self.assertIsNone(index)
def test_remove_connection(self): filename = os.path.join(self.data_dir, "test_1.mo") new_filename = os.path.join(self.output_dir, "test_1_output_8.mo") f1 = InputParser(filename) f1.remove_connect_string('weaDat.weaBus', 'weaBus') f1.save_as(new_filename) f2 = InputParser(new_filename) self.assertFalse(filecmp.cmp(filename, new_filename)) index, c = f2.find_connect('weaDat.weaBus', 'weaBus') # the connection should no longer exist self.assertIsNone(index)
def test_remove_connection(self): filename = os.path.abspath('tests/modelica/data/test_1.mo') new_filename = os.path.abspath('tests/modelica/output/test_1_output_8.mo') f1 = InputParser(filename) f1.remove_connect_string('weaDat.weaBus', 'weaBus') f1.save_as(new_filename) f2 = InputParser(new_filename) self.assertFalse(filecmp.cmp(filename, new_filename)) index, c = f2.find_connect('weaDat.weaBus', 'weaBus') # the connection should no longer exist self.assertIsNone(index)
def test_gsub_connect(self): filename = os.path.join(self.data_dir, "test_1.mo") new_filename = os.path.join(self.output_dir, "test_1_output_6.mo") f1 = InputParser(filename) f1.add_connect( "port_a", "thermalZoneTwoElements.intGainsConv", "annotation (Line(points={{0,100},{96,100},{96,20},{92,20}}, color={191,0,0}))", ) f1.save_as(new_filename) # verify in the new file that the new model object exists f2 = InputParser(new_filename) self.assertFalse(filecmp.cmp(filename, new_filename)) index, c = f2.find_connect("port_a", "thermalZoneTwoElements.intGainsConv") self.assertGreaterEqual(index, 0)