---------- restore_list (list): the list to restore from """ self.instance_id = restore_list[0] self.command = restore_list[1] def verify(self): """ Perform an integrity check on local variables. Returns True if values are valid, and False otherwise. """ raise NotImplementedError ############################################################################### # Unit testing if __name__ == "__main__": a = CommandPayload() a.instance_id = "instance_id" a.command = "command" b = CommandPayload.decode(a.encode()) print "\nTest Print:" print a print "\nTesting:" test_eq(a, b, "Encode/Decode") test_eq(eval(repr(a)), a, "Eval/Repr")
reg_payload.instance_id = "instnace_id" reg_payload.sys_info = dict({1: 2}) data_payload = DataPayload() for i in xrange(4): data_payload.add_item("name" + str(i), "s", "valu" + str(i), "unit" + str(i), "note" + str(i)) msg = Message() msg.append(data_payload) msg.append(data_payload) msg_str = msg.encode() msg1 = Message.decode(msg_str) test_eq(msg, msg1, "Message (Data) Encode/Decode") msg2 = Message() msg2.append(reg_payload) msg2.append(reg_payload) msg_str2 = msg2.encode() msg3 = Message.decode(msg_str2) test_eq(msg2, msg3, "Message (Reg) Encode/Decode") msg4 = Message() msg4.append(cmd_payload) msg4.append(cmd_payload) msg_str4 = msg4.encode()