Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests, add mocking, switch to lxml
- Loading branch information
Showing
7 changed files
with
140 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lxml>=3.6,<3.7 | ||
pytest>=2.9,<2.10 | ||
pytest-mock>=1.1,<1.2 | ||
requests>=2.10,<2.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<device-info> | ||
<udn>00000000-1111-2222-3333-444444444444</udn> | ||
<serial-number>111111111111</serial-number> | ||
<device-id>222222222222</device-id> | ||
<vendor-name>Roku</vendor-name> | ||
<model-number>4200X</model-number> | ||
<model-name>Roku 3</model-name> | ||
<wifi-mac>00:11:22:33:44:55</wifi-mac> | ||
<ethernet-mac>00:11:22:33:44:56</ethernet-mac> | ||
<network-type>ethernet</network-type> | ||
<user-device-name/> | ||
<software-version>7.00</software-version> | ||
<software-build>09044</software-build> | ||
<secure-device>true</secure-device> | ||
<language>en</language> | ||
<country>US</country> | ||
<locale>en_US</locale> | ||
<time-zone>US/Eastern</time-zone> | ||
<time-zone-offset>-300</time-zone-offset> | ||
<power-mode>PowerOn</power-mode> | ||
<developer-enabled>false</developer-enabled> | ||
<search-enabled>true</search-enabled> | ||
<voice-search-enabled>true</voice-search-enabled> | ||
<notifications-enabled>true</notifications-enabled> | ||
<notifications-first-use>false</notifications-first-use> | ||
<headphones-connected>false</headphones-connected> | ||
</device-info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from contextlib import closing | ||
|
||
from lxml import etree as ET | ||
from six import BytesIO | ||
|
||
|
||
def deserialize_apps(doc, roku=None): | ||
|
||
from .core import Application | ||
|
||
applications = [] | ||
root = ET.fromstring(doc) | ||
for elem in root: | ||
app = Application( | ||
id=elem.get('id'), version=elem.get('version'), name=elem.text) | ||
applications.append(app) | ||
return applications | ||
|
||
|
||
def serialize_apps(apps): | ||
|
||
root = ET.Element('apps') | ||
|
||
for app in apps: | ||
attrs = {'id': app.id, 'version': app.version} | ||
elem = ET.SubElement(root, 'app', attrs) | ||
elem.text = app.name | ||
|
||
with closing(BytesIO()) as bffr: | ||
tree = ET.ElementTree(root) | ||
tree.write(bffr, xml_declaration=True, encoding="utf-8") | ||
content = bffr.getvalue() | ||
|
||
return content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ envlist = py27,py35 | |
|
||
[testenv] | ||
deps= | ||
lxml | ||
pytest | ||
pytest-mock | ||
commands=py.test |