예제 #1
0
 def test_attach_tracker_rejects_receipts(self):
     self.msg.xep0184_received = mdr_xso.Received("foo")
     with self.assertRaisesRegex(
             ValueError,
             r"requesting delivery receipts for delivery receipts is not "
             r"allowed"):
         self.s.attach_tracker(self.msg, self.t)
예제 #2
0
    def test_handle_state_exception_from_tracker(self):
        self.msg.to = self.msg.to.replace(resource="foo")
        self.s.attach_tracker(self.msg, self.t)

        ack = aioxmpp.Message(type_=aioxmpp.MessageType.CHAT,
                              from_=TEST_TO.replace(resource="foo"))
        ack.xep0184_received = mdr_xso.Received(self.msg.id_)

        self.t._set_state(aioxmpp.tracking.MessageState.SEEN_BY_RECIPIENT)

        self.assertIsNone(self.s._inbound_message_filter(ack))

        self.assertEqual(
            self.t.state,
            aioxmpp.tracking.MessageState.SEEN_BY_RECIPIENT,
        )
예제 #3
0
    def test_do_not_modify_tracker_state_on_id_mismatch(self):
        self.msg.to = self.msg.to.replace(resource="foo")
        self.s.attach_tracker(self.msg, self.t)

        ack = aioxmpp.Message(type_=aioxmpp.MessageType.CHAT,
                              from_=TEST_TO.replace(resource="foo"))
        ack.xep0184_received = mdr_xso.Received("fnord")

        self.assertEqual(
            self.t.state,
            aioxmpp.tracking.MessageState.IN_TRANSIT,
        )
        self.assertIsNone(self.s._inbound_message_filter(ack))

        self.assertEqual(
            self.t.state,
            aioxmpp.tracking.MessageState.IN_TRANSIT,
        )
예제 #4
0
    def test_set_tracker_state_to_DTR_on_ack_for_full_match(self):
        self.msg.to = self.msg.to.replace(resource="foo")
        self.s.attach_tracker(self.msg, self.t)

        ack = aioxmpp.Message(type_=aioxmpp.MessageType.CHAT,
                              from_=TEST_TO.replace(resource="foo"))
        ack.xep0184_received = mdr_xso.Received(self.msg.id_)

        self.assertEqual(
            self.t.state,
            aioxmpp.tracking.MessageState.IN_TRANSIT,
        )
        self.assertIsNone(self.s._inbound_message_filter(ack))

        self.assertEqual(
            self.t.state,
            aioxmpp.tracking.MessageState.DELIVERED_TO_RECIPIENT,
        )
예제 #5
0
    def test_raises_on_receipt(self):
        self.msg.xep0184_received = mdr_xso.Received("foo")

        with self.assertRaisesRegex(
                ValueError, r"receipts cannot be generated for receipts"):
            mdr_service.compose_receipt(self.msg)
예제 #6
0
 def test_init(self):
     r = mdr_xso.Received("foobar")
     self.assertEqual(r.message_id, "foobar")
예제 #7
0
 def test_init_default(self):
     with self.assertRaisesRegex(TypeError, "message_id"):
         mdr_xso.Received()