test_compat_utils.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from __future__ import absolute_import, unicode_literals
  2. import pytest
  3. import celery
  4. from celery.app.task import Task as ModernTask
  5. from celery.task.base import Task as CompatTask
  6. @pytest.mark.usefixtures('depends_on_current_app')
  7. class test_MagicModule:
  8. def test_class_property_set_without_type(self):
  9. assert ModernTask.__dict__['app'].__get__(CompatTask())
  10. def test_class_property_set_on_class(self):
  11. assert (ModernTask.__dict__['app'].__set__(None, None) is
  12. ModernTask.__dict__['app'])
  13. def test_class_property_set(self, app):
  14. class X(CompatTask):
  15. pass
  16. ModernTask.__dict__['app'].__set__(X(), app)
  17. assert X.app is app
  18. def test_dir(self):
  19. assert dir(celery.messaging)
  20. def test_direct(self):
  21. assert celery.task
  22. def test_app_attrs(self):
  23. assert (celery.task.control.broadcast ==
  24. celery.current_app.control.broadcast)
  25. def test_decorators_task(self):
  26. @celery.decorators.task
  27. def _test_decorators_task():
  28. pass
  29. def test_decorators_periodic_task(self):
  30. @celery.decorators.periodic_task(run_every=3600)
  31. def _test_decorators_ptask():
  32. pass