test_check_am2_compatibility.py 914 B

123456789101112131415161718192021222324252627
  1. from unittest.mock import patch
  2. import pytest
  3. from sentry.tasks.check_am2_compatibility import (
  4. CheckStatus,
  5. get_check_status,
  6. run_compatibility_check_async,
  7. )
  8. from sentry.testutils.cases import TestCase
  9. pytestmark = pytest.mark.sentry_metrics
  10. class CheckAM2CompatibilityTest(TestCase):
  11. def test_check_with_success(self):
  12. with self.tasks():
  13. run_compatibility_check_async(org_id=self.organization.id)
  14. assert get_check_status(self.organization.id) == CheckStatus.DONE
  15. @patch("sentry.tasks.check_am2_compatibility.CheckAM2Compatibility.run_compatibility_check")
  16. def test_check_with_error(self, run_compatibility_check):
  17. run_compatibility_check.side_effect = Exception
  18. with self.tasks():
  19. run_compatibility_check_async(org_id=self.organization.id)
  20. assert get_check_status(self.organization.id) == CheckStatus.ERROR