def test_msg_delete(self): q = self.queue mgr = q._message_manager claim_id = utils.random_unicode() mgr.delete = Mock() msg = QueueMessage(manager=mgr, info={}) msg.delete(claim_id=claim_id) mgr.delete.assert_called_once_with(msg, claim_id=claim_id)
def test_msg_add_details_no_href(self): id_ = utils.random_unicode() claim_id = utils.random_unicode() age = utils.random_unicode() body = utils.random_unicode() ttl = utils.random_unicode() href = None info = {"href": href, "age": age, "body": body, "ttl": ttl, } msg = QueueMessage(manager=None, info=info) self.assertIsNone(msg.id) self.assertIsNone(msg.claim_id)
def test_msg_add_details_claim(self): id_ = _safe_id() claim_id = _safe_id() age = utils.random_unicode() body = utils.random_unicode() ttl = utils.random_unicode() href = "http://example.com/%s?claim_id=%s" % (id_, claim_id) info = {"href": href, "age": age, "body": body, "ttl": ttl, } msg = QueueMessage(manager=None, info=info) self.assertEqual(msg.id, id_) self.assertEqual(msg.claim_id, claim_id)
def test_msg_add_details(self): id_ = _safe_id() claim_id = utils.random_unicode() age = utils.random_unicode() body = utils.random_unicode() ttl = utils.random_unicode() href = "http://example.com/%s" % id_ info = {"href": href, "age": age, "body": body, "ttl": ttl, } msg = QueueMessage(manager=None, info=info) self.assertEqual(msg.id, id_) self.assertIsNone(msg.claim_id) self.assertEqual(msg.age, age) self.assertEqual(msg.body, body) self.assertEqual(msg.ttl, ttl) self.assertEqual(msg.href, href)