You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

  1. from django.test.utils import override_settings
  2. from hc.test import BaseTestCase
  3. @override_settings(SLACK_CLIENT_ID="fake-client-id")
  4. class AddSlackBtnTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(AddSlackBtnTestCase, self).setUp()
  7. self.url = "/projects/%s/add_slack_btn/" % self.project.code
  8. def test_instructions_work(self):
  9. self.client.login(username="[email protected]", password="password")
  10. r = self.client.get(self.url)
  11. self.assertContains(r, "Setup Guide", status_code=200)
  12. def test_slack_button(self):
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.get(self.url)
  15. self.assertContains(r, "slack.com/oauth/authorize", status_code=200)
  16. # There should now be a key in session
  17. self.assertTrue("add_slack" in self.client.session)
  18. @override_settings(SLACK_CLIENT_ID=None)
  19. def test_it_requires_client_id(self):
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get(self.url)
  22. self.assertEqual(r.status_code, 404)