Skip to content

Commit 27a5ea2

Browse files
committed
black formatting
1 parent ac5f405 commit 27a5ea2

6 files changed

Lines changed: 50 additions & 71 deletions

File tree

roku/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from roku.core import ( # noqa
2-
Roku, Application, Channel, RokuException, __version__)
1+
from roku.core import Roku, Application, Channel, RokuException, __version__ # noqa

roku/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ def __getitem__(self, key):
216216

217217
def __dir__(self):
218218
return sorted(
219-
dir(type(self)) +
220-
list(self.__dict__.keys()) +
221-
list(COMMANDS.keys()) +
222-
list(SENSORS)
219+
dir(type(self))
220+
+ list(self.__dict__.keys())
221+
+ list(COMMANDS.keys())
222+
+ list(SENSORS)
223223
)
224224

225225
def _app_for_name(self, name):

roku/discovery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def __repr__(self):
2828

2929

3030
def discover(timeout=2, retries=1, st=ST_ECP):
31-
3231
group = ("239.255.255.250", 1900)
3332

3433
message = "\r\n".join(

roku/emulator/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from roku import Application
22

33
DEFAULT_APPS = [
4-
Application(1, '1.0', 'Hulu Plus'),
5-
Application(2, '2.0', 'TWiT'),
6-
Application(3, '3.0', 'Whisky Media'),
7-
Application(4, '4.0', 'Netflix'),
4+
Application(1, "1.0", "Hulu Plus"),
5+
Application(2, "2.0", "TWiT"),
6+
Application(3, "3.0", "Whisky Media"),
7+
Application(4, "4.0", "Netflix"),
88
]
99

1010

1111
class Emulator(object):
12-
1312
def __init__(self, apps=None):
1413
self._apps = apps or DEFAULT_APPS
1514

roku/tests/test_roku.py

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212

1313

1414
class Fauxku(Roku):
15-
1615
def __init__(self, *args, **kwargs):
1716
super(Fauxku, self).__init__(*args, **kwargs)
1817
self._calls = []
1918

2019
def _call(self, method, path, *args, **kwargs):
2120
self._calls.append((method, path, args, kwargs))
22-
return ''
21+
return ""
2322

2423
def calls(self):
2524
return self._calls
@@ -30,38 +29,36 @@ def last_call(self):
3029

3130
@pytest.fixture
3231
def roku():
33-
return Fauxku('0.0.0.0')
32+
return Fauxku("0.0.0.0")
3433

3534

3635
@pytest.fixture
3736
def apps(roku):
3837
faux_apps = [
39-
Application('11', '1.0.1', 'Fauxku Channel Store', roku),
40-
Application('22', '2.0.2', 'Faux Netflix', roku),
41-
Application('33', '3.0.3', 'Faux YouTube', roku),
42-
Application('44HL', '4.0.4', 'Faux Hulu', roku),
38+
Application("11", "1.0.1", "Fauxku Channel Store", roku),
39+
Application("22", "2.0.2", "Faux Netflix", roku),
40+
Application("33", "3.0.3", "Faux YouTube", roku),
41+
Application("44HL", "4.0.4", "Faux Hulu", roku),
4342
]
4443
return faux_apps
4544

4645

4746
def test_apps(mocker, roku):
47+
faux_apps = (Application("0x", "1.2.3", "Fauxku Channel Store"),)
4848

49-
faux_apps = (Application('0x', '1.2.3', 'Fauxku Channel Store'),)
50-
51-
mocked_get = mocker.patch.object(Roku, '_get')
49+
mocked_get = mocker.patch.object(Roku, "_get")
5250
mocked_get.return_value = serialize_apps(faux_apps)
5351

5452
apps = roku.apps
5553

5654
assert len(apps) == 1
57-
assert apps[0].id == '0x'
58-
assert apps[0].version == '1.2.3'
59-
assert apps[0].name == 'Fauxku Channel Store'
55+
assert apps[0].id == "0x"
56+
assert apps[0].version == "1.2.3"
57+
assert apps[0].name == "Fauxku Channel Store"
6058

6159

6260
def test_app_selector(mocker, apps):
63-
64-
mocked_get = mocker.patch.object(Roku, '_get')
61+
mocked_get = mocker.patch.object(Roku, "_get")
6562
mocked_get.return_value = serialize_apps(apps)
6663

6764
for app in apps:
@@ -71,113 +68,99 @@ def test_app_selector(mocker, apps):
7168

7269

7370
def test_device_info(mocker, roku):
74-
75-
xml_path = os.path.join(TESTS_PATH, 'responses', 'device-info.xml')
71+
xml_path = os.path.join(TESTS_PATH, "responses", "device-info.xml")
7672
with open(xml_path) as infile:
7773
content = infile.read()
7874

79-
mocked_get = mocker.patch.object(Roku, '_get')
80-
mocked_get.return_value = content.encode('utf-8')
75+
mocked_get = mocker.patch.object(Roku, "_get")
76+
mocked_get.return_value = content.encode("utf-8")
8177

8278
d = roku.device_info
8379

84-
assert d.model_name == 'Roku 3'
85-
assert d.model_num == '4200X'
86-
assert d.software_version == '7.00.09044'
87-
assert d.serial_num == '111111111111'
88-
assert d.roku_type == 'Stick'
80+
assert d.model_name == "Roku 3"
81+
assert d.model_num == "4200X"
82+
assert d.software_version == "7.00.09044"
83+
assert d.serial_num == "111111111111"
84+
assert d.roku_type == "Stick"
8985

9086

9187
def test_media_player(mocker, roku):
92-
93-
xml_path = os.path.join(TESTS_PATH, 'responses', 'media-player.xml')
88+
xml_path = os.path.join(TESTS_PATH, "responses", "media-player.xml")
9489
with open(xml_path) as infile:
9590
content = infile.read()
9691

97-
faux_apps = (Application(33, '1.2.3', 'Faux YouTube'),)
92+
faux_apps = (Application(33, "1.2.3", "Faux YouTube"),)
9893

99-
mocked_get = mocker.patch.object(Roku, '_get')
100-
mocked_get.return_value = content.encode('utf-8')
101-
mocker.patch.object(Roku, 'apps', new=faux_apps)
94+
mocked_get = mocker.patch.object(Roku, "_get")
95+
mocked_get.return_value = content.encode("utf-8")
96+
mocker.patch.object(Roku, "apps", new=faux_apps)
10297

10398
m = roku.media_player
10499

105-
assert m.state == 'pause'
106-
assert m.app.name == 'Faux YouTube'
100+
assert m.state == "pause"
101+
assert m.app.name == "Faux YouTube"
107102
assert m.position == 11187
108103
assert m.duration == 1858000
109104

110105

111106
def test_commands(roku):
112-
113107
for cmd in roku.commands:
114-
115-
if cmd in ['literal', 'search']:
108+
if cmd in ["literal", "search"]:
116109
# there is a separate test for the literal and search command
117110
continue
118111

119112
getattr(roku, cmd)()
120113
call = roku.last_call()
121114

122-
assert call == ('POST', f'/keypress/{COMMANDS[cmd]}', (), {})
115+
assert call == ("POST", f"/keypress/{COMMANDS[cmd]}", (), {})
123116

124117

125118
def test_search(roku):
126-
127-
text = 'Stargate'
119+
text = "Stargate"
128120
roku.search(title=text)
129121

130122
call = roku.last_call()
131123

132-
assert call == ('POST', '/search/browse', (), {'params': {'title': text}})
124+
assert call == ("POST", "/search/browse", (), {"params": {"title": text}})
133125

134126

135127
def test_literal(roku):
136-
137-
text = 'Stargate'
128+
text = "Stargate"
138129
roku.literal(text)
139130

140131
for i, call in enumerate(roku.calls()):
141-
assert call == (
142-
'POST', f'/keypress/Lit_{quote_plus(text[i])}', (), {})
132+
assert call == ("POST", f"/keypress/Lit_{quote_plus(text[i])}", (), {})
143133

144134

145135
def test_literal_fancy(roku):
146-
147136
text = r"""~!@#$%^&*()_+`-=[]{};':",./<>?\|€£"""
148137
roku.literal(text)
149138

150139
for i, call in enumerate(roku.calls()):
151-
assert call == (
152-
'POST', f'/keypress/Lit_{quote_plus(text[i])}', (), {})
140+
assert call == ("POST", f"/keypress/Lit_{quote_plus(text[i])}", (), {})
153141

154142

155143
def test_store(apps):
156-
157144
for app in apps:
158-
159145
roku = app.roku
160146
roku.store(app)
161147
call = roku.last_call()
162148

163-
params = {'params': {'contentID': app.id}}
164-
assert call == ('POST', '/launch/11', (), params)
149+
params = {"params": {"contentID": app.id}}
150+
assert call == ("POST", "/launch/11", (), params)
165151

166152

167153
def test_launch(apps):
168-
169154
for app in apps:
170-
171155
roku = app.roku
172156
roku.launch(app)
173157
call = roku.last_call()
174158

175-
params = {'params': {'contentID': app.id}}
176-
assert call == ('POST', f'/launch/{app.id}', (), params)
159+
params = {"params": {"contentID": app.id}}
160+
assert call == ("POST", f"/launch/{app.id}", (), params)
177161

178162

179163
def test_icon_url(apps):
180-
181164
for app in apps:
182165
assert app.roku.icon_url(app) == f"http://0.0.0.0:8060/query/icon/{app.id}"
183166
assert app.icon_url == f"http://0.0.0.0:8060/query/icon/{app.id}"

roku/util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
def deserialize_apps(doc, roku=None):
8-
98
from .core import Application
109

1110
applications = []
@@ -19,7 +18,6 @@ def deserialize_apps(doc, roku=None):
1918

2019

2120
def serialize_apps(apps):
22-
2321
root = ET.Element("apps")
2422

2523
for app in apps:
@@ -36,15 +34,16 @@ def serialize_apps(apps):
3634

3735

3836
def deserialize_channels(doc, roku=None):
39-
4037
from .core import Channel
4138

4239
channels = []
4340
root = ET.fromstring(doc)
4441

4542
for elem in root:
4643
channel = Channel(
47-
number=elem.find("number").text, name=elem.find("name").text, roku=roku,
44+
number=elem.find("number").text,
45+
name=elem.find("name").text,
46+
roku=roku,
4847
)
4948
channels.append(channel)
5049
return channels

0 commit comments

Comments
 (0)