-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_ps4.py
More file actions
95 lines (74 loc) · 2.82 KB
/
test_ps4.py
File metadata and controls
95 lines (74 loc) · 2.82 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# -*- coding: utf-8 -*-
import os
from nose.tools import eq_, ok_
from mock import MagicMock
import pyps4
CREDENTIALS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'credentials.json')
class TestPs4(object):
def test_ps4(self):
playstation = pyps4.Ps4('10.10.10.10')
eq_(playstation._host, '10.10.10.10')
eq_(playstation._broadcast, False)
playstation = pyps4.Ps4(None, broadcast=True)
eq_(playstation._host, None)
eq_(playstation._broadcast, True)
playstation = pyps4.Ps4('10.10.10.10', credential='abcdef')
eq_(playstation._credential, 'abcdef')
playstation = pyps4.Ps4('0.0.0.0', credentials_file=CREDENTIALS_FILE)
eq_(playstation._credential, '1234567890')
def test_open_credentials_file(self):
creds = pyps4.open_credential_file(CREDENTIALS_FILE)
ok_('client-type' in creds)
ok_('auth-type' in creds)
ok_('user-credential' in creds)
def test_get_host_status(self):
mock = MagicMock()
mock.side_effect = [
{'status_code': 200},
{'status_code': 620},
]
playstation = pyps4.Ps4('10.10.10.10')
playstation.get_status = mock
eq_(playstation.get_host_status(), 200)
eq_(playstation.get_host_status(), 620)
def test_is_running(self):
mock = MagicMock()
mock.side_effect = [
{'status_code': 200},
{'status_code': 620},
{'status_code': 100},
]
playstation = pyps4.Ps4('10.10.10.10')
playstation.get_status = mock
eq_(playstation.is_running(), True)
eq_(playstation.is_running(), False)
eq_(playstation.is_running(), False)
def test_is_standby(self):
mock = MagicMock()
mock.side_effect = [
{'status_code': 620},
{'status_code': 200},
{'status_code': 100},
]
playstation = pyps4.Ps4('10.10.10.10')
playstation.get_status = mock
eq_(playstation.is_standby(), True)
eq_(playstation.is_standby(), False)
eq_(playstation.is_standby(), False)
def test_get_host_id(self):
mock = MagicMock()
mock.side_effect = [
{'host-id': 'test-A'},
{'host-name': 'test-B'},
{'running-app-titleid': 'test-C: C'},
{'running-app-name': 'test-D'},
{'system-version': 'test-E'},
]
playstation = pyps4.Ps4('10.10.10.10')
playstation.get_status = mock
eq_(playstation.get_host_id(), 'test-A')
eq_(playstation.get_host_name(), 'test-B')
eq_(playstation.get_running_app_titleid(), 'test-C: C')
eq_(playstation.get_running_app_name(), 'test-D')
eq_(playstation.get_system_version(), 'test-E')