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.

39 lines
1.2 KiB

  1. import json
  2. from django.test.utils import override_settings
  3. from hc.api.models import Channel
  4. from hc.test import BaseTestCase
  5. class AddTrelloTestCase(BaseTestCase):
  6. def setUp(self):
  7. super(AddTrelloTestCase, self).setUp()
  8. self.url = "/projects/%s/add_trello/" % self.project.code
  9. @override_settings(TRELLO_APP_KEY="foo")
  10. def test_instructions_work(self):
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.get(self.url)
  13. self.assertContains(r, "Trello")
  14. @override_settings(TRELLO_APP_KEY="foo")
  15. def test_it_works(self):
  16. form = {
  17. "settings": json.dumps(
  18. {
  19. "token": "fake-token",
  20. "board_name": "My Board",
  21. "list_name": "My List",
  22. "list_id": "fake-list-id",
  23. }
  24. )
  25. }
  26. self.client.login(username="[email protected]", password="password")
  27. r = self.client.post(self.url, form)
  28. self.assertRedirects(r, self.channels_url)
  29. c = Channel.objects.get()
  30. self.assertEqual(c.kind, "trello")
  31. self.assertEqual(c.trello_token, "fake-token")
  32. self.assertEqual(c.project, self.project)