test_plugin.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from functools import cached_property
  2. import responses
  3. from django.test import RequestFactory
  4. from sentry.testutils import PluginTestCase
  5. from sentry_plugins.phabricator.plugin import PhabricatorPlugin
  6. class PhabricatorPluginTest(PluginTestCase):
  7. @cached_property
  8. def plugin(self):
  9. return PhabricatorPlugin()
  10. @cached_property
  11. def request(self):
  12. return RequestFactory()
  13. def test_conf_key(self):
  14. assert self.plugin.conf_key == "phabricator"
  15. def test_entry_point(self):
  16. self.assertPluginInstalled("phabricator", self.plugin)
  17. def test_get_issue_label(self):
  18. group = self.create_group(message="Hello world", culprit="foo.bar")
  19. assert self.plugin.get_issue_label(group, 1) == "T1"
  20. @responses.activate
  21. def test_get_issue_url(self):
  22. self.plugin.set_option("host", "http://secure.phabricator.org", self.project)
  23. group = self.create_group(message="Hello world", culprit="foo.bar")
  24. assert self.plugin.get_issue_url(group, "1") == "http://secure.phabricator.org/T1"
  25. def test_is_configured(self):
  26. assert self.plugin.is_configured(None, self.project) is False
  27. self.plugin.set_option("host", "http://secure.phabricator.org", self.project)
  28. assert self.plugin.is_configured(None, self.project) is False
  29. self.plugin.set_option("token", "12345678-1234-1234-1234-1234567890AB", self.project)
  30. assert self.plugin.is_configured(None, self.project) is True
  31. self.plugin.unset_option("token", self.project)
  32. self.plugin.set_option("username", "a-user", self.project)
  33. assert self.plugin.is_configured(None, self.project) is False
  34. self.plugin.set_option("certificate", "a-certificate", self.project)
  35. assert self.plugin.is_configured(None, self.project) is True