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.

26 lines
925 B

  1. from unittest.mock import patch
  2. from django.test.utils import override_settings
  3. from hc.test import BaseTestCase
  4. @override_settings(TRELLO_APP_KEY="foo")
  5. class AddTrelloTestCase(BaseTestCase):
  6. url = "/integrations/add_trello/settings/"
  7. @patch("hc.front.views.requests.get")
  8. def test_it_works(self, mock_get):
  9. mock_get.return_value.json.return_value = [
  10. {"name": "My Board", "lists": [{"name": "Alerts"}]}
  11. ]
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.post(self.url)
  14. self.assertContains(r, "Please select the Trello list")
  15. self.assertContains(r, "Alerts")
  16. @override_settings(TRELLO_APP_KEY=None)
  17. def test_it_requires_trello_app_key(self):
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.get(self.url)
  20. self.assertEqual(r.status_code, 404)