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())
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 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)