Skip to content

Commit e8f056b

Browse files
author
Dave Mun
committed
Update test_session_creation.py to expects module
1 parent 777f145 commit e8f056b

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

tests/test_session_creation.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from six import text_type, u, b, PY2, PY3
33
from six.moves.urllib.parse import parse_qs
44
from nose.tools import raises
5-
from sure import expect
5+
from expects import *
66
import httpretty
77
from .validate_jwt import validate_jwt_header
88

@@ -24,14 +24,14 @@ def test_create_default_session(self):
2424
session = self.opentok.create_session()
2525

2626
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
27-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
27+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
2828
body = parse_qs(httpretty.last_request().body)
29-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('enabled')])
30-
expect(body).to.have.key(b('archiveMode')).being.equal([b('manual')])
31-
expect(session).to.be.a(Session)
32-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
33-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
34-
expect(session).to.have.property(u('location')).being.equal(None)
29+
expect(body).to(have_key(b('p2p.preference'), [b('enabled')]))
30+
expect(body).to(have_key(b('archiveMode'), [b('manual')]))
31+
expect(session).to(be_a(Session))
32+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
33+
expect(session).to(have_property(u('media_mode'), MediaModes.relayed))
34+
expect(session).to(have_property(u('location'), None))
3535

3636
@httpretty.activate
3737
def test_create_routed_session(self):
@@ -43,14 +43,14 @@ def test_create_routed_session(self):
4343
session = self.opentok.create_session(media_mode=MediaModes.routed)
4444

4545
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
46-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
46+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
4747
body = parse_qs(httpretty.last_request().body)
48-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
49-
expect(body).to.have.key(b('archiveMode')).being.equal([b('manual')])
50-
expect(session).to.be.a(Session)
51-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
52-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
53-
expect(session).to.have.property(u('location')).being.equal(None)
48+
expect(body).to(have_key(b('p2p.preference'), [b('disabled')]))
49+
expect(body).to(have_key(b('archiveMode'), [b('manual')]))
50+
expect(session).to(be_a(Session))
51+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
52+
expect(session).to(have_property(u('media_mode'), MediaModes.routed))
53+
expect(session).to(have_property(u('location'), None))
5454

5555
@httpretty.activate
5656
def test_create_session_with_location_hint(self):
@@ -62,15 +62,15 @@ def test_create_session_with_location_hint(self):
6262
session = self.opentok.create_session(location='12.34.56.78')
6363

6464
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
65-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
65+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
6666
# ordering of keys is non-deterministic, must parse the body to see if it is correct
6767
body = parse_qs(httpretty.last_request().body)
68-
expect(body).to.have.key(b('location')).being.equal([b('12.34.56.78')])
69-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('enabled')])
70-
expect(session).to.be.a(Session)
71-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
72-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.relayed)
73-
expect(session).to.have.property(u('location')).being.equal(u('12.34.56.78'))
68+
expect(body).to(have_key(b('location'), [b('12.34.56.78')]))
69+
expect(body).to(have_key(b('p2p.preference'), [b('enabled')]))
70+
expect(session).to(be_a(Session))
71+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
72+
expect(session).to(have_property(u('media_mode'), MediaModes.relayed))
73+
expect(session).to(have_property(u('location'), u('12.34.56.78')))
7474

7575
@httpretty.activate
7676
def test_create_routed_session_with_location_hint(self):
@@ -82,15 +82,15 @@ def test_create_routed_session_with_location_hint(self):
8282
session = self.opentok.create_session(location='12.34.56.78', media_mode=MediaModes.routed)
8383

8484
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
85-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
85+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
8686
# ordering of keys is non-deterministic, must parse the body to see if it is correct
8787
body = parse_qs(httpretty.last_request().body)
88-
expect(body).to.have.key(b('location')).being.equal([b('12.34.56.78')])
89-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
90-
expect(session).to.be.a(Session)
91-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
92-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
93-
expect(session).to.have.property(u('location')).being.equal(u('12.34.56.78'))
88+
expect(body).to(have_key(b('location'), [b('12.34.56.78')]))
89+
expect(body).to(have_key(b('p2p.preference'), [b('disabled')]))
90+
expect(session).to(be_a(Session))
91+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
92+
expect(session).to(have_property(u('media_mode'), MediaModes.routed))
93+
expect(session).to(have_property(u('location'), u('12.34.56.78')))
9494

9595
@httpretty.activate
9696
def test_create_manual_archive_mode_session(self):
@@ -102,14 +102,14 @@ def test_create_manual_archive_mode_session(self):
102102
session = self.opentok.create_session(media_mode=MediaModes.routed, archive_mode=ArchiveModes.manual)
103103

104104
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
105-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
105+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
106106
body = parse_qs(httpretty.last_request().body)
107-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
108-
expect(body).to.have.key(b('archiveMode')).being.equal([b('manual')])
109-
expect(session).to.be.a(Session)
110-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
111-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
112-
expect(session).to.have.property(u('archive_mode')).being.equal(ArchiveModes.manual)
107+
expect(body).to(have_key(b('p2p.preference'), [b('disabled')]))
108+
expect(body).to(have_key(b('archiveMode'), [b('manual')]))
109+
expect(session).to(be_a(Session))
110+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
111+
expect(session).to(have_property(u('media_mode'), MediaModes.routed))
112+
expect(session).to(have_property(u('archive_mode'), ArchiveModes.manual))
113113

114114
@httpretty.activate
115115
def test_create_always_archive_mode_session(self):
@@ -121,14 +121,14 @@ def test_create_always_archive_mode_session(self):
121121
session = self.opentok.create_session(media_mode=MediaModes.routed, archive_mode=ArchiveModes.always)
122122

123123
validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
124-
expect(httpretty.last_request().headers[u('user-agent')]).to.contain(u('OpenTok-Python-SDK/')+__version__)
124+
expect(httpretty.last_request().headers[u('user-agent')]).to(contain(u('OpenTok-Python-SDK/')+__version__))
125125
body = parse_qs(httpretty.last_request().body)
126-
expect(body).to.have.key(b('p2p.preference')).being.equal([b('disabled')])
127-
expect(body).to.have.key(b('archiveMode')).being.equal([b('always')])
128-
expect(session).to.be.a(Session)
129-
expect(session).to.have.property(u('session_id')).being.equal(u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg'))
130-
expect(session).to.have.property(u('media_mode')).being.equal(MediaModes.routed)
131-
expect(session).to.have.property(u('archive_mode')).being.equal(ArchiveModes.always)
126+
expect(body).to(have_key(b('p2p.preference'), [b('disabled')]))
127+
expect(body).to(have_key(b('archiveMode'), [b('always')]))
128+
expect(session).to(be_a(Session))
129+
expect(session).to(have_property(u('session_id'), u('1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg')))
130+
expect(session).to(have_property(u('media_mode'), MediaModes.routed))
131+
expect(session).to(have_property(u('archive_mode'), ArchiveModes.always))
132132

133133
@httpretty.activate
134134
def test_complains_about_always_archive_mode_and_relayed_session(self):

0 commit comments

Comments
 (0)