Exemple #1
0
 def test_from_message_nonexistant_task(self):
     body = {"task": "cu.mytask.doesnotexist", "id": gen_unique_id(),
             "args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
     m = BaseMessage(body=simplejson.dumps(body), backend="foo",
                     content_type="application/json",
                     content_encoding="utf-8")
     self.assertRaises(NotRegistered, TaskRequest.from_message,
                       m, m.decode())
Exemple #2
0
 def test_from_message_nonexistant_task(self):
     body = {"task": "cu.mytask.doesnotexist", "id": gen_unique_id(),
             "args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
     m = BaseMessage(body=simplejson.dumps(body), backend="foo",
                     content_type="application/json",
                     content_encoding="utf-8")
     self.assertRaises(NotRegistered, TaskRequest.from_message,
                       m, m.decode())
Exemple #3
0
 def test_from_message(self):
     body = {"task": mytask.name, "id": gen_unique_id(), "args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
     m = BaseMessage(
         body=simplejson.dumps(body), backend="foo", content_type="application/json", content_encoding="utf-8"
     )
     tw = TaskRequest.from_message(m, m.decode())
     self.assertIsInstance(tw, TaskRequest)
     self.assertEqual(tw.task_name, body["task"])
     self.assertEqual(tw.task_id, body["id"])
     self.assertEqual(tw.args, body["args"])
     self.assertEqual(tw.kwargs.keys()[0], u"æØåveéðƒeæ".encode("utf-8"))
     self.assertNotIsInstance(tw.kwargs.keys()[0], unicode)
     self.assertTrue(tw.logger)
Exemple #4
0
 def test_from_message(self):
     body = {"task": mytask.name, "id": gen_unique_id(),
             "args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
     m = BaseMessage(body=simplejson.dumps(body), backend="foo",
                     content_type="application/json",
                     content_encoding="utf-8")
     tw = TaskRequest.from_message(m, m.decode())
     self.assertIsInstance(tw, TaskRequest)
     self.assertEqual(tw.task_name, body["task"])
     self.assertEqual(tw.task_id, body["id"])
     self.assertEqual(tw.args, body["args"])
     self.assertEqual(tw.kwargs.keys()[0],
                       u"æØåveéðƒeæ".encode("utf-8"))
     self.assertNotIsInstance(tw.kwargs.keys()[0], unicode)
     self.assertTrue(tw.logger)
def create_message(backend, **data):
    data.setdefault("id", gen_unique_id())
    return BaseMessage(backend,
                       body=pickle.dumps(dict(**data)),
                       content_type="application/x-python-serialize",
                       content_encoding="binary")