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.

23 lines
679 B

  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. channel = Channel(kind="hipchat", user=self.alice, value=json.dumps({
  10. "oauthId": "foo",
  11. "oauthSecret": "bar"
  12. }))
  13. channel.refresh_hipchat_access_token()
  14. # It should request a token using a correct tokenUrl
  15. mock_post.assert_called()
  16. self.assertTrue("expires_at" in channel.value)