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.

32 lines
1.2 KiB

  1. from django.test.utils import override_settings
  2. from hc.test import BaseTestCase
  3. @override_settings(LINENOTIFY_CLIENT_ID="t1", LINENOTIFY_CLIENT_SECRET="s1")
  4. class AddLineNotifyTestCase(BaseTestCase):
  5. def setUp(self):
  6. super().setUp()
  7. self.url = "/projects/%s/add_linenotify/" % 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, "notify-bot.line.me/oauth/authorize", status_code=200)
  12. self.assertContains(r, "Connect LINE Notify")
  13. # There should now be a key in session
  14. self.assertTrue("add_linenotify" in self.client.session)
  15. @override_settings(LINENOTIFY_CLIENT_ID=None)
  16. def test_it_requires_client_id(self):
  17. self.client.login(username="[email protected]", password="password")
  18. r = self.client.get(self.url)
  19. self.assertEqual(r.status_code, 404)
  20. def test_it_requires_rw_access(self):
  21. self.bobs_membership.rw = False
  22. self.bobs_membership.save()
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.get(self.url)
  25. self.assertEqual(r.status_code, 403)