test_migrate.py 761 B

123456789101112131415161718192021222324252627
  1. from __future__ import absolute_import, unicode_literals
  2. import pytest
  3. from case import Mock, patch
  4. from celery.bin.migrate import migrate
  5. from celery.five import WhateverIO
  6. class test_migrate:
  7. @patch('celery.contrib.migrate.migrate_tasks')
  8. def test_run(self, migrate_tasks):
  9. out = WhateverIO()
  10. m = migrate(app=self.app, stdout=out, stderr=WhateverIO())
  11. with pytest.raises(TypeError):
  12. m.run()
  13. migrate_tasks.assert_not_called()
  14. m.run('memory://foo', 'memory://bar')
  15. migrate_tasks.assert_called()
  16. state = Mock()
  17. state.count = 10
  18. state.strtotal = 30
  19. m.on_migrate_task(state, {'task': 'tasks.add', 'id': 'ID'}, None)
  20. assert '10/30' in out.getvalue()