Skip to content
Browse files

Adds more tests

  • Loading branch information...
1 parent 7c8d7ff commit 9ba5fcb19c806ed6697a7a998afc5b59f8423439 @ask ask committed Jan 9, 2012
View
8 celery/execute/trace.py
@@ -42,14 +42,6 @@
RETRY = states.RETRY
FAILURE = states.FAILURE
EXCEPTION_STATES = states.EXCEPTION_STATES
-_pid = None
-
-
-def getpid():
- global _pid
- if _pid is None:
- _pid = os.getpid()
- return _pid
class TraceInfo(object):
View
27 celery/tests/test_app/test_actors.py
@@ -0,0 +1,27 @@
+from __future__ import absolute_import
+
+from kombu import BrokerConnection
+
+from celery.actors import Actor, Agent, AwareAgent
+
+from celery.tests.utils import AppCase
+
+
+class test_using_connection(AppCase):
+
+ def assertConnection(self, cls):
+ x = cls(app=self.app)
+ self.assertTrue(x.connection)
+
+ conn = BrokerConnection(transport="memory")
+ x = cls(app=self.app, connection=conn)
+ self.assertIs(x.connection, conn)
+
+ def test_Actor(self):
+ self.assertConnection(Actor)
+
+ def test_Agent(self):
+ self.assertConnection(Agent)
+
+ def test_AwareAgent(self):
+ self.assertConnection(AwareAgent)
View
53 celery/tests/test_app/test_annotations.py
@@ -0,0 +1,53 @@
+from __future__ import absolute_import
+
+from celery.app.annotations import MapAnnotation, prepare
+from celery.task import task
+from celery.utils import qualname
+
+from celery.tests.utils import unittest
+
+
+@task
+def add(x, y):
+ return x + y
+
+
+@task
+def mul(x, y):
+ return x * y
+
+
+class MyAnnotation(object):
+ foo = 65
+
+
+class test_MapAnnotation(unittest.TestCase):
+
+ def test_annotate(self):
+ x = MapAnnotation({add.name: {"foo": 1}})
+ self.assertDictEqual(x.annotate(add), {"foo": 1})
+ self.assertIsNone(x.annotate(mul))
+
+ def test_annotate_any(self):
+ x = MapAnnotation({'*': {"foo": 2}})
+ self.assertDictEqual(x.annotate_any(), {"foo": 2})
+
+ x = MapAnnotation()
+ self.assertIsNone(x.annotate_any())
+
+
+class test_prepare(unittest.TestCase):
+
+ def test_dict_to_MapAnnotation(self):
+ x = prepare({add.name: {"foo": 3}})
+ self.assertIsInstance(x[0], MapAnnotation)
+
+ def test_returns_list(self):
+ self.assertListEqual(prepare(1), [1])
+ self.assertListEqual(prepare([1]), [1])
+ self.assertListEqual(prepare((1, )), [1])
+ self.assertEqual(prepare(None), ())
+
+ def test_evalutes_qualnames(self):
+ self.assertEqual(prepare(qualname(MyAnnotation))[0]().foo, 65)
+ self.assertEqual(prepare([qualname(MyAnnotation)])[0]().foo, 65)
View
10 celery/tests/test_utils/__init__.py
@@ -1,16 +1,26 @@
from __future__ import absolute_import
+from __future__ import with_statement
import pickle
from celery import utils
from celery.utils import promise, mpromise, maybe_promise
+from celery.utils.threads import bgThread
from celery.tests.utils import unittest
def double(x):
return x * 2
+class test_bgThread_interface(unittest.TestCase):
+
+ def test_body(self):
+ x = bgThread()
+ with self.assertRaises(NotImplementedError):
+ x.body()
+
+
class test_chunks(unittest.TestCase):
def test_chunks(self):
View
8 celery/utils/threads.py
@@ -10,19 +10,19 @@
class Event(_Event):
- if not hasattr(_Event, "is_set"):
+ if not hasattr(_Event, "is_set"): # pragma: no cover
is_set = _Event.isSet
class Thread(_Thread):
- if not hasattr(_Thread, "is_alive"):
+ if not hasattr(_Thread, "is_alive"): # pragma: no cover
is_alive = _Thread.isAlive
- if not hasattr(_Thread, "daemon"):
+ if not hasattr(_Thread, "daemon"): # pragma: no cover
daemon = property(_Thread.isDaemon, _Thread.setDaemon)
- if not hasattr(_Thread, "name"):
+ if not hasattr(_Thread, "name"): # pragma: no cover
name = property(_Thread.getName, _Thread.setName)
View
2 setup.cfg
@@ -12,12 +12,14 @@ cover3-exclude = celery
celery.execute
celery.local
celery.platforms
+ celery.utils.encoding
celery.utils.patch
celery.utils.compat
celery.utils.mail
celery.utils.functional
celery.utils.dispatch*
celery.utils.term
+ celery.messaging
celery.db.a805d4bd
celery.db.dfd042c7
celery.contrib*

0 comments on commit 9ba5fcb

Please sign in to comment.
Something went wrong with that request. Please try again.