test_plugin.py 1.8 KB

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