-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathtests.py
More file actions
66 lines (48 loc) · 2.03 KB
/
tests.py
File metadata and controls
66 lines (48 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""Unit tests for pymsl"""
import unittest
from Cryptodome.PublicKey import RSA
import pymsl
from pymsl.exceptions import LicenseError, ManifestError, UserAuthDataError
class MslClientTests(unittest.TestCase):
"""Unit tests for the MslClient itself"""
def test_kwargs(self):
"""
This function tests the kwargs for the MslClient initialization
to make sure that they are properly set
"""
esn = 'NFCDIE-02-TDP0LTTSNSC3EHLL71FRYFOEEAZYQ3'
drm_system = 'playready'
profiles = ['ddplus-5.1-dash']
keypair = RSA.generate(2048)
message_id = 123456789
languages = ['de-DE']
client = pymsl.MslClient(
{'scheme': 'EMAIL_PASSWORD'},
esn=esn,
drm_system=drm_system,
profiles=profiles,
keypair=keypair,
message_id=message_id,
languages=languages
)
self.assertEqual(esn, client.msl_session['esn'])
self.assertEqual(drm_system, client.msl_session['drm_system'])
self.assertEqual(profiles, client.msl_session['profiles'])
self.assertEqual(keypair, client.msl_session['keypair'])
self.assertEqual(message_id, client.msl_session['message_id'])
self.assertEqual(languages, client.msl_session['languages'])
class MslExceptionTests(unittest.TestCase):
"""Unit tests for the MslClient exceptions"""
def test_license_exception(self):
"""Test for LicenseError exception"""
client = pymsl.MslClient({'scheme': 'EMAIL_PASSWORD'})
self.assertRaises(LicenseError, client.get_license, b'', '')
def test_manifest_exception(self):
"""Test for ManifestError exception"""
client = pymsl.MslClient({'scheme': 'EMAIL_PASSWORD'})
self.assertRaises(ManifestError, client.load_manifest, 80092521)
def test_user_auth_exception(self):
"""Test for UserAuthDataError exception"""
self.assertRaises(UserAuthDataError, pymsl.MslClient, {})
if __name__ == '__main__':
unittest.main()