test_referrer.py 992 B

123456789101112131415161718192021222324252627
  1. from unittest import TestCase
  2. from unittest.mock import patch
  3. from sentry.snuba.referrer import ReferrerBase, validate_referrer
  4. from sentry.tsdb.base import TSDBModel
  5. class ReferrerTest(TestCase):
  6. @patch("sentry.snuba.referrer.logger.warning")
  7. def test_referrer_validate_not_exist(self, warn_log):
  8. assert warn_log.call_count == 0
  9. validate_referrer("does_not_exist")
  10. assert warn_log.call_count == 1
  11. @patch("sentry.snuba.referrer.logger.warning")
  12. def test_referrer_validate_dynamic_tsdb_model(self, warn_log):
  13. assert warn_log.call_count == 0
  14. for model in TSDBModel:
  15. validate_referrer(f"tsdb-modelid:{model.value}")
  16. assert warn_log.call_count == 0
  17. @patch("sentry.snuba.referrer.logger.warning")
  18. def test_referrer_validate_base_enum_values(self, warn_log):
  19. assert warn_log.call_count == 0
  20. for i in ReferrerBase:
  21. validate_referrer(i.value)
  22. assert warn_log.call_count == 0