Browse Source

Tests now running again.

Ask Solem 16 years ago
parent
commit
c42189e0f3
3 changed files with 15 additions and 19 deletions
  1. 2 2
      celery/managers.py
  2. 2 2
      celery/tests/test_models.py
  3. 11 15
      celery/tests/test_task.py

+ 2 - 2
celery/managers.py

@@ -10,11 +10,11 @@ class TaskManager(models.Manager):
         return task
 
     def is_done(self, task_id):
-        return self.get_task(task_id).is_done
+        return self.get_task(task_id).status == "DONE"
 
     def get_all_expired(self):
         return self.filter(date_done__lt=datetime.now() - timedelta(days=5),
-                           is_done=True)
+                           status="DONE")
 
     def delete_expired(self):
         self.get_all_expired().delete()

+ 2 - 2
celery/tests/test_models.py

@@ -33,8 +33,8 @@ class TestModels(unittest.TestCase):
         self.assertEquals(TaskMeta.objects.get_task(m1.task_id).task_id,
                 m1.task_id)
         self.assertFalse(TaskMeta.objects.is_done(m1.task_id))
-        TaskMeta.objects.mark_as_done(m1.task_id)
-        TaskMeta.objects.mark_as_done(m2.task_id)
+        TaskMeta.objects.mark_as_done(m1.task_id, True)
+        TaskMeta.objects.mark_as_done(m2.task_id, True)
         self.assertTrue(TaskMeta.objects.is_done(m1.task_id))
         self.assertTrue(TaskMeta.objects.is_done(m2.task_id))
 

+ 11 - 15
celery/tests/test_task.py

@@ -37,11 +37,11 @@ class TestCeleryTasks(unittest.TestCase):
         cls.run = return_True
         return cls
 
-    def assertNextTaskDataEquals(self, consumer, task_id, task_name,
+    def assertNextTaskDataEquals(self, consumer, presult, task_name,
             **kwargs):
         next_task = consumer.fetch()
         task_data = consumer.decoder(next_task.body)
-        self.assertEquals(task_data["id"], task_id)
+        self.assertEquals(task_data["id"], presult.task_id)
         self.assertEquals(task_data["task"], task_name)
         task_kwargs = task_data.get("kwargs", {})
         for arg_name, arg_value in kwargs.items():
@@ -83,12 +83,12 @@ class TestCeleryTasks(unittest.TestCase):
         self.assertTrue(consumer.fetch() is None)
 
         # Without arguments.
-        tid = t1.delay()
-        self.assertNextTaskDataEquals(consumer, tid, t1.name)
+        presult = t1.delay()
+        self.assertNextTaskDataEquals(consumer, presult, t1.name)
 
         # With arguments.
-        tid2 = task.delay_task(t1.name, name="George Constanza")
-        self.assertNextTaskDataEquals(consumer, tid2, t1.name,
+        presult2 = task.delay_task(t1.name, name="George Constanza")
+        self.assertNextTaskDataEquals(consumer, presult2, t1.name,
                 name="George Constanza")
 
         self.assertRaises(registry.tasks.NotRegistered, task.delay_task,
@@ -100,20 +100,16 @@ class TestCeleryTasks(unittest.TestCase):
         self.assertEquals(task.discard_all(), 1)
         self.assertTrue(consumer.fetch() is None)
 
-        self.assertFalse(task.is_done(tid))
-        task.mark_as_done(tid, result=None)
-        self.assertTrue(task.is_done(tid))
+        self.assertFalse(task.is_done(presult.task_id))
+        self.assertFalse(presult.is_done())
+        task.mark_as_done(presult.task_id, result=None)
+        self.assertTrue(task.is_done(presult.task_id))
+        self.assertTrue(presult.is_done())
 
 
         publisher = t1.get_publisher()
         self.assertTrue(isinstance(publisher, messaging.TaskPublisher))
 
-    def test_taskmeta_cache(self):
-        # TODO Needs to test task meta without TASK_META_USE_DB.
-        tid = str(uuid.uuid4())
-        ckey = task.gen_task_done_cache_key(tid)
-        self.assertTrue(ckey.rfind(tid) != -1)
-
 
 class TestTaskSet(unittest.TestCase):