8000 test: update tox config and replace deprecated test functions (#636) · twilio/twilio-python@eabfaa9 · GitHub
[go: up one dir, main page]

Skip to content

Commit eabfaa9

Browse files
author
childish-sambino
committed
test: update tox config and replace deprecated test functions (#636)
1 parent a25ab50 commit eabfaa9

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

.github/workflows/test-and-deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ jobs:
3232
- name: Install Dependencies
3333
run: |
3434
pip install virtualenv --upgrade
35-
make install
36-
make test-install
35+
make install test-install
3736
3837
- name: Run the tests
3938
run: make test-with-coverage

tests/unit/jwt/test_access_token.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
SyncGrant,
99
VoiceGrant,
1010
VideoGrant,
11-
ConversationsGrant,
1211
TaskRouterGrant,
1312
ChatGrant,
1413
PlaybackGrant,
@@ -95,16 +94,18 @@ def test_identity(self):
9594

9695
def test_conversations_grant(self):
9796
scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret')
98-
scat.add_grant(ConversationsGrant(configuration_profile_sid='CP123'))
97+
scat.add_grant(VoiceGrant(outgoing_application_sid='CP123'))
9998

10099
token = scat.to_jwt()
101100
assert token is not None
102101
decoded_token = AccessToken.from_jwt(token, 'secret')
103102
self._validate_claims(decoded_token.payload)
104103
assert 1 == len(decoded_token.payload['grants'])
105104
assert {
106-
'configuration_profile_sid': 'CP123'
107-
} == decoded_token.payload['grants']['rtc']
105+
'outgoing': {
106+
'application_sid': 'CP123'
107+
}
108+
} == decoded_token.payload['grants']['voice']
108109

109110
def test_video_grant(self):
110111
scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret')

tests/unit/jwt/test_client_validation.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import unittest
21
import time
2+
import unittest
33

44
from cryptography.hazmat.backends import default_backend
55
from cryptography.hazmat.primitives.asymmetric import rsa
@@ -11,7 +11,6 @@
1111
)
1212

1313
from twilio.http.validation_client import ValidationPayload
14-
from twilio.jwt import Jwt
1514
from twilio.jwt.validation import ClientValidationJwt
1615

1716

@@ -231,12 +230,12 @@ def test_jwt_payload(self):
231230

232231
jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp)
233232

234-
self.assertDictContainsSubset({
233+
self.assertEqual(jwt.payload, {**jwt.payload, **{
235234
'hrh': 'authorization;host',
236235
'rqh': expected_hash,
237236
'iss': 'SK123',
238237
'sub': 'AC123',
239-
}, jwt.payload)
238+
}})
240239
self.assertGreaterEqual(jwt.payload['exp'], time.time(), 'JWT exp is before now')
241240
self.assertLessEqual(jwt.payload['exp'], time.time() + 301, 'JWT exp is after now + 5mins')
242241
self.assertDictEqual({
@@ -268,12 +267,12 @@ def test_jwt_signing(self):
268267
jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', private_key, vp)
269268
decoded = ClientValidationJwt.from_jwt(jwt.to_jwt(), public_key)
270269

271-
self.assertDictContainsSubset({
270+
self.assertEqual(decoded.payload, {**decoded.payload, **{
272271
'hrh': 'authorization;hos 8000 t',
273272
'rqh': expected_hash,
274273
'iss': 'SK123',
275274
'sub': 'AC123',
276-
}, decoded.payload)
275+
}})
277276
self.assertGreaterEqual(decoded.payload['exp'], time.time(), 'JWT exp is before now')
278277
self.assertLessEqual(decoded.payload['exp'], time.time() + 501, 'JWT exp is after now + 5m')
279278
self.assertDictEqual({

tests/unit/jwt/test_jwt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ def test_encode_decode(self):
203203
self.assertEqual(decoded_jwt.subject, 'hey')
204204

205205
self.assertEqual(decoded_jwt.headers, {'typ': 'JWT', 'alg': 'HS256'})
206-
self.assertDictContainsSubset({
206+
self.assertEqual(decoded_jwt.payload, {**decoded_jwt.payload, **{
207207
'iss': 'issuer',
208208
'sub': 'hey',
209209
'sick': 'sick',
210-
}, decoded_jwt.payload)
210+
}})
211211

212212
def test_encode_decode_mismatched_algorithms(self):
213213
jwt = DummyJwt('secret_key', 'issuer', algorithm='HS512', subject='hey', payload={'sick': 'sick'})

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[tox]
2-
envlist = py3{7,8,9,10,11}, pypy
2+
env_list = py3{7,8,9,10,11}, pypy
33
skip_missing_interpreters = true
44

55
[testenv]
6-
deps= -r{toxinidir}/tests/requirements.txt
7-
commands=
8-
nosetests \
9-
[]
6+
deps = -r{tox_root}/tests/requirements.txt
7+
commands =
8+
pytest \
9+
[]

0 commit comments

Comments
 (0)
0