forked from digidotcom/python-devicecloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sci.py
More file actions
44 lines (34 loc) · 1.61 KB
/
Copy pathtest_sci.py
File metadata and controls
44 lines (34 loc) · 1.61 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2014 Etherios, Inc. All rights reserved.
# Etherios, Inc. is a Division of Digi International.
import unittest
from devicecloud.sci import DeviceTarget
from devicecloud.test.test_utilities import HttpTestBase
import httpretty
import six
EXAMPLE_SCI_DEVICE_NOT_CONNECTED = """\
<sci_reply version="1.0"><reboot><device id="00000000-00000000-00409DFF-FF58175B"><error id="2001"><desc>Device Not Connected</desc></error></device></reboot></sci_reply>
"""
class TestSCI(HttpTestBase):
def _prepare_sci_response(self, response, status=200):
self.prepare_response("POST", "/ws/sci", response, status)
def test_sci_successful_error(self):
self._prepare_sci_response(EXAMPLE_SCI_DEVICE_NOT_CONNECTED)
self.dc.get_sci_api().send_sci(
operation="send_message",
target=DeviceTarget("00000000-00000000-00409DFF-FF58175B"),
payload="<reset/>")
self.assertEqual(httpretty.last_request().body,
six.b('<sci_request version="1.0">'
'<send_message>'
'<targets>'
'<device id="00000000-00000000-00409DFF-FF58175B"/>'
'</targets>'
'<reset/>'
'</send_message>'
'</sci_request>'))
if __name__ == "__main__":
unittest.main()