Skip to content

Commit 7d2d7ff

Browse files
committed
test timeout http option
1 parent 6a04d4c commit 7d2d7ff

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/test_http_options.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
import unittest
2-
from six import text_type, u, b, PY2, PY3
3-
from six.moves.urllib.parse import parse_qs
42
from nose.tools import raises
5-
from sure import expect
63
import httpretty
4+
import requests
75

8-
from opentok import OpenTok, Session, MediaModes, OpenTokException, __version__
6+
from opentok import OpenTok, OpenTokException
7+
8+
def _raise_timeout(*args):
9+
raise requests.Timeout('Timeout occurred')
910

1011
class OpenTokSessionCreationTest(unittest.TestCase):
1112
def setUp(self):
1213
self.api_key = u('123456')
1314
self.api_secret = u('1234567890abcdef1234567890abcdef1234567890')
1415
httpretty.enable()
1516
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/session/create'),
16-
body=u('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon Mar 17 00:41:31 PDT 2014</create_dt></Session></sessions>'),
17+
body=_raise_timeout,
1718
status=200,
1819
content_type=u('text/xml'))
1920

2021
def tearDown(self):
2122
httpretty.disable()
2223

24+
@raises(OpenTokException)
2325
def test_timeout(self):
24-
# TODO: tell httpretty to timeout
25-
opentok = OpenTok(self.api_key, self.api_secret, timeout=5)
26-
27-
session = opentok.create_session()
28-
29-
# TODO: expect an exception
26+
opentok = OpenTok(self.api_key, self.api_secret, timeout=1)
27+
opentok.create_session()

0 commit comments

Comments
 (0)