test_plugin.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import responses
  2. from django.test import RequestFactory
  3. from exam import fixture
  4. from sentry.testutils import PluginTestCase
  5. from sentry_plugins.phabricator.plugin import PhabricatorPlugin
  6. class PhabricatorPluginTest(PluginTestCase):
  7. @fixture
  8. def plugin(self):
  9. return PhabricatorPlugin()
  10. @fixture
  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