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.

24 lines
706 B

6 years ago
6 years ago
  1. import json
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. from mock import patch
  5. class ChannelModelTestCase(BaseTestCase):
  6. @patch("hc.api.models.requests.post")
  7. def test_it_refreshes_hipchat_access_token(self, mock_post):
  8. mock_post.return_value.json.return_value = {"expires_in": 100}
  9. value = json.dumps({
  10. "oauthId": "foo",
  11. "oauthSecret": "bar"
  12. })
  13. channel = Channel(kind="hipchat", project=self.project, value=value)
  14. channel.refresh_hipchat_access_token()
  15. # It should request a token using a correct tokenUrl
  16. mock_post.assert_called()
  17. self.assertTrue("expires_at" in channel.value)