Exemplo n.º 1
0
    def test_incomingReceipt_multi(self):
        from yowsup_ext.layers.store.models.state import State

        messages = [self.sendMessage(), self.sendMessage(), self.sendMessage()]

        #get acks
        for message in messages:
            self.receiveAck(message)

        #get receipt
        receipt = IncomingReceiptProtocolEntity(
            str(time.time()),
            messages[0].getTo(),
            str(int(time.time())),
            items=[message.getId() for message in messages])

        self.stack.receive(receipt)

        # check
        for message in messages:
            state = self.getMessageState(message.getId())
            self.assertEqual(state.name, State.get_sent_delivered().name)

        receipt.type = "read"

        self.stack.receive(receipt)

        for message in messages:
            state = self.getMessageState(message.getId())
            self.assertEqual(state.name, State.get_sent_read().name)
Exemplo n.º 2
0
    def test_incomingReceipt_multi(self):
        from yowsup_ext.layers.store.models.state import State

        messages = [self.sendMessage(), self.sendMessage(), self.sendMessage()]

        #get acks
        for message in messages:
            self.receiveAck(message)

        #get receipt
        receipt = IncomingReceiptProtocolEntity(str(time.time()), messages[0].getTo(),
            str(int(time.time())),
            items = [message.getId() for message in messages])

        self.stack.receive(receipt)

        # check
        for message in messages:
            state = self.getMessageState(message.getId())
            self.assertEqual(state.name, State.get_sent_delivered().name)


        receipt.type = "read"

        self.stack.receive(receipt)

        for message in messages:
            state = self.getMessageState(message.getId())
            self.assertEqual(state.name, State.get_sent_read().name)
Exemplo n.º 3
0
    def test_storeOutgoingTextMessages(self):
        from yowsup_ext.layers.store.models.state import State
        from yowsup_ext.layers.store.models.messagestate import MessageState
        from yowsup_ext.layers.store.models.message import Message
        msg = self.sendMessage()

        message = self.stack.getLayerInterface(YowStorageLayer).getMessages(
            msg.getTo(), limit=1)[0]

        self.assertEqual(message.content, msg.getBody())
        self.assertEqual(message.conversation.contact.jid, msg.getTo())
        states = (State.select().join(MessageState).join(Message).where(
            Message.id == message.id))

        self.assertEqual(states[0], State.get_sent_queued())
Exemplo n.º 4
0
    def test_incomingReceipt(self):
        from yowsup_ext.layers.store.models.state import State
        message = self.sendMessage()
        ack = self.receiveAck(message)

        receipt = IncomingReceiptProtocolEntity(message.getId(), message.getTo(), str(int(time.time())))
        self.stack.receive(receipt)

        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent_delivered().name)

        receipt.type = "read"

        self.stack.receive(receipt)
        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent_read().name)
Exemplo n.º 5
0
    def test_incomingAck(self):
        from yowsup_ext.layers.store.models.state import State
        message = self.sendMessage()
        self.receiveAck(message)

        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent().name)
Exemplo n.º 6
0
    def test_incomingAck(self):
        from yowsup_ext.layers.store.models.state import State
        message = self.sendMessage()
        self.receiveAck(message)

        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent().name)
Exemplo n.º 7
0
    def test_storeIncomingTextMessage(self):
        from yowsup_ext.layers.store.models.messagestate import MessageState
        from yowsup_ext.layers.store.models.message import Message
        from yowsup_ext.layers.store.models.state import State

        msg = self.receiveMessage()
        self.sendReceipt(msg)

        message = Message.get(id_gen=msg.getId())

        self.assertEqual(message.content, msg.getBody())
        self.assertEqual(message.conversation.contact.jid, msg.getFrom())
        states = (State.select().join(MessageState).join(Message).where(
            Message.id == message.id))

        self.assertEqual(states[0].name, State.get_received_remote().name)
        self.sendReceipt(msg, read=True)
Exemplo n.º 8
0
    def test_incomingReceipt(self):
        from yowsup_ext.layers.store.models.state import State
        message = self.sendMessage()
        ack = self.receiveAck(message)

        receipt = IncomingReceiptProtocolEntity(message.getId(),
                                                message.getTo(),
                                                str(int(time.time())))
        self.stack.receive(receipt)

        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent_delivered().name)

        receipt.type = "read"

        self.stack.receive(receipt)
        state = self.getMessageState(message.getId())
        self.assertEqual(state.name, State.get_sent_read().name)
Exemplo n.º 9
0
    def getMessageState(self, messageGenId):
        from yowsup_ext.layers.store.models.messagestate import MessageState
        from yowsup_ext.layers.store.models.message import Message
        from yowsup_ext.layers.store.models.state import State

        message = self.stack.getLayerInterface(
            YowStorageLayer).getMessageByGenId(messageGenId)

        states = (State.select().join(MessageState).join(Message).where(
            Message.id == message.id))

        return states[0]
Exemplo n.º 10
0
    def test_storeOutgoingTextMessages(self):
        from yowsup_ext.layers.store.models.state import State
        from yowsup_ext.layers.store.models.messagestate import MessageState
        from yowsup_ext.layers.store.models.message import Message
        msg = self.sendMessage()

        message = self.stack.getLayerInterface(YowStorageLayer).getMessages(msg.getTo(), limit=1)[0]

        self.assertEqual(message.content, msg.getBody())
        self.assertEqual(message.conversation.contact.jid, msg.getTo())
        states = (State
            .select()
            .join(MessageState)
            .join(Message)
            .where(Message.id == message.id))

        self.assertEqual(states[0], State.get_sent_queued())
Exemplo n.º 11
0
    def test_storeIncomingTextMessage(self):
        from yowsup_ext.layers.store.models.messagestate import MessageState
        from yowsup_ext.layers.store.models.message import Message
        from yowsup_ext.layers.store.models.state import State

        msg = self.receiveMessage()
        self.sendReceipt(msg)

        message = Message.get(id_gen = msg.getId())

        self.assertEqual(message.content, msg.getBody())
        self.assertEqual(message.conversation.contact.jid, msg.getFrom())
        states = (State
            .select()
            .join(MessageState)
            .join(Message)
            .where(Message.id == message.id))

        self.assertEqual(states[0].name, State.get_received_remote().name)
        self.sendReceipt(msg, read=True)