def test_to_representation_several_lines(self): db = messages.DataBlock(data_lines=[ messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]), messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]), messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]), ]) assert db.to_representation() == ("3:14(314*kWh)4:15(415*kWh)\r\n" "3:14(314*kWh)4:15(415*kWh)\r\n" "3:14(314*kWh)4:15(415*kWh)\r\n") def test_to_representation_single_line(self): db = messages.DataBlock(data_lines=[ messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]) ]) assert db.to_representation() == "3:14(314*kWh)4:15(415*kWh)\r\n"
def test_to_representation(self): rdm = messages.ReadoutDataMessage(data_block=messages.DataBlock( data_lines=[ messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]) ])) assert rdm.to_representation( ) == '\x023:14(314*kWh)4:15(415*kWh)\r\n!\r\n\x03"'
def test_to_representation(self): db = messages.DataBlock(data_lines=[ messages.DataLine(data_sets=[ messages.DataSet(address="3:14", value="314", unit="kWh"), messages.DataSet(address="4:15", value="415", unit="kWh"), ]) ]) am = messages.AnswerDataMessage(data_block=db) assert am.to_representation( ) == "\x023:14(314*kWh)4:15(415*kWh)\r\n\x03\x04"