test_states.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from __future__ import absolute_import, unicode_literals
  2. import pytest
  3. from celery import states
  4. class test_state_precedence:
  5. @pytest.mark.parametrize('r,l', [
  6. (states.SUCCESS, states.PENDING),
  7. (states.FAILURE, states.RECEIVED),
  8. (states.REVOKED, states.STARTED),
  9. (states.SUCCESS, 'CRASHED'),
  10. (states.FAILURE, 'CRASHED'),
  11. ])
  12. def test_gt(self, r, l):
  13. assert states.state(r) > states.state(l)
  14. @pytest.mark.parametrize('r,l', [
  15. ('CRASHED', states.REVOKED),
  16. ])
  17. def test_gte(self, r, l):
  18. assert states.state(r) >= states.state(l)
  19. @pytest.mark.parametrize('r,l', [
  20. (states.PENDING, states.SUCCESS),
  21. (states.RECEIVED, states.FAILURE),
  22. (states.STARTED, states.REVOKED),
  23. ('CRASHED', states.SUCCESS),
  24. ('CRASHED', states.FAILURE),
  25. (states.REVOKED, 'CRASHED'),
  26. ])
  27. def test_lt(self, r, l):
  28. assert states.state(r) < states.state(l)
  29. @pytest.mark.parametrize('r,l', [
  30. (states.REVOKED, 'CRASHED'),
  31. ])
  32. def test_lte(self, r, l):
  33. assert states.state(r) <= states.state(l)