def get_request(self): "return MessageRequest" mc = MessageChannels(name=super(MessageDbRequestTest, self).get_input_collapse_key()) mc.id = self.collapse_key_id mc.save() for key, data in self.get_input_data().items(): md = MessageData(data=data) if type(key) is int: md.id = key else: md.name = key md.save() mc.message.add(md) mc.save() mg = MessageGroups(name="test_all_db") mg.save() ad = AndroidDevice() ad.id = 1000 ad.device_id = "test_send_message_db_01" ad.registration_id = self.get_input_registration_id() ad.save() dci = DeviceChannelInfo() dci.device = ad dci.channel = mc dci.save() return msg_db.MessageRequest(dci, self.get_input_delay_while_idle())
def get_message(self): self.collapse_key = "col_key" self.registration_id = "reg_id" self.data_in = {"key1": "data1", "key2": "data2"} self.delay_while_idle = False mc = MessageChannels(name=self.collapse_key) mc.id = 100 mc.save() for key, data in self.data_in.items(): md = MessageData(data=data) if type(key) is int: md.id = key else: md.name = key md.save() mc.message.add(md) mc.save() mg = MessageGroups(name="test_all_db") mg.save() ad = AndroidDevice() ad.id = 1000 ad.device_id = "test_send_message_db_01" ad.registration_id = self.registration_id ad.save() dci = DeviceChannelInfo() dci.device = ad dci.channel = mc dci.save() self.dci_id = dci.id message_request = msg_db.MessageRequest(dci, self.delay_while_idle) message_response = msg_db.MessageResponse(dci) return message_request, message_response