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.0 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. from mock import patch
  4. class AddMatrixTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(AddMatrixTestCase, self).setUp()
  7. self.url = "/projects/%s/add_matrix/" % 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, "Integration Settings", status_code=200)
  12. @patch("hc.front.forms.requests.post")
  13. def test_it_works(self, mock_post):
  14. mock_post.return_value.json.return_value = {"room_id": "fake-room-id"}
  15. form = {"alias": "!foo:example.org"}
  16. self.client.login(username="[email protected]", password="password")
  17. r = self.client.post(self.url, form)
  18. self.assertRedirects(r, self.channels_url)
  19. c = Channel.objects.get()
  20. self.assertEqual(c.kind, "matrix")
  21. self.assertEqual(c.value, "fake-room-id")
  22. self.assertEqual(c.project, self.project)