test_compat_utils.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from __future__ import absolute_import, unicode_literals
  2. import celery
  3. import pytest
  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