test_states.py 1.1 KB

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