Skip to content

Commit 70743a9

Browse files
committed
adding tests for new e2ee kwarg in create_session method
1 parent 75830a3 commit 70743a9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

opentok/opentok.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ def create_session(
400400
location=location,
401401
media_mode=media_mode,
402402
archive_mode=archive_mode,
403+
e2ee=e2ee,
403404
)
404405
except Exception as e:
405406
raise OpenTokException("Failed to generate session: %s" % str(e))

tests/test_session_creation.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_create_default_session(self):
5454
)
5555
expect(session).to(have_property(u("media_mode"), MediaModes.relayed))
5656
expect(session).to(have_property(u("location"), None))
57+
expect(session).to(have_property(u("e2ee"), False))
5758

5859
@httpretty.activate
5960
def test_create_routed_session(self):
@@ -87,6 +88,7 @@ def test_create_routed_session(self):
8788
)
8889
expect(session).to(have_property(u("media_mode"), MediaModes.routed))
8990
expect(session).to(have_property(u("location"), None))
91+
expect(session).to(have_property(u("e2ee"), False))
9092

9193
@httpretty.activate
9294
def test_failure_create_routed_session(self):
@@ -138,6 +140,7 @@ def test_create_session_with_location_hint(self):
138140
)
139141
expect(session).to(have_property(u("media_mode"), MediaModes.relayed))
140142
expect(session).to(have_property(u("location"), u("12.34.56.78")))
143+
expect(session).to(have_property(u("e2ee"), False))
141144

142145
@httpretty.activate
143146
def test_create_routed_session_with_location_hint(self):
@@ -174,6 +177,7 @@ def test_create_routed_session_with_location_hint(self):
174177
)
175178
expect(session).to(have_property(u("media_mode"), MediaModes.routed))
176179
expect(session).to(have_property(u("location"), u("12.34.56.78")))
180+
expect(session).to(have_property(u("e2ee"), False))
177181

178182
@httpretty.activate
179183
def test_create_manual_archive_mode_session(self):
@@ -209,6 +213,7 @@ def test_create_manual_archive_mode_session(self):
209213
)
210214
expect(session).to(have_property(u("media_mode"), MediaModes.routed))
211215
expect(session).to(have_property(u("archive_mode"), ArchiveModes.manual))
216+
expect(session).to(have_property(u("e2ee"), False))
212217

213218
@httpretty.activate
214219
def test_create_always_archive_mode_session(self):
@@ -244,6 +249,7 @@ def test_create_always_archive_mode_session(self):
244249
)
245250
expect(session).to(have_property(u("media_mode"), MediaModes.routed))
246251
expect(session).to(have_property(u("archive_mode"), ArchiveModes.always))
252+
expect(session).to(have_property(u("e2ee"), False))
247253

248254
@httpretty.activate
249255
def test_complains_about_always_archive_mode_and_relayed_session(self):
@@ -263,5 +269,32 @@ def test_complains_about_always_archive_mode_and_relayed_session(self):
263269
archive_mode=ArchiveModes.always,
264270
)
265271

272+
@httpretty.activate
273+
def test_create_session_with_e2ee(self):
274+
httpretty.register_uri(
275+
httpretty.POST,
276+
u("https://api.opentok.com/session/create"),
277+
body=u(
278+
'<?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>'
279+
),
280+
status=200,
281+
content_type=u("text/xml"),
282+
)
283+
284+
session = self.opentok.create_session(e2ee=True)
285+
286+
body = parse_qs(httpretty.last_request().body)
287+
expect(body).to(have_key(b("e2ee"), [b'True']))
288+
expect(session).to(be_a(Session))
289+
expect(session).to(
290+
have_property(
291+
u("session_id"),
292+
u(
293+
"1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg"
294+
),
295+
)
296+
)
297+
expect(session).to(have_property(u("e2ee"), True))
298+
266299
# TODO: all the cases that throw exceptions
267300
# TODO: custom api_url requests

0 commit comments

Comments
 (0)