forked from openviess/PyViCare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_PyViCareService.py
27 lines (20 loc) · 1.13 KB
/
test_PyViCareService.py
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
import unittest
from unittest.mock import Mock
from PyViCare.PyViCareService import ViCareDeviceAccessor, ViCareService
class PyViCareServiceTest(unittest.TestCase):
def setUp(self):
self.oauth_mock = Mock()
accessor = ViCareDeviceAccessor("[id]", "[serial]", "[device]")
self.service = ViCareService(self.oauth_mock, accessor, [])
def test_getProperty(self):
self.service.getProperty("someprop")
self.oauth_mock.get.assert_called_once_with(
'/equipment/installations/[id]/gateways/[serial]/devices/[device]/features/someprop')
def test_setProperty_object(self):
self.service.setProperty("someprop", "doaction", {'name': 'abc'})
self.oauth_mock.post.assert_called_once_with(
'/equipment/installations/[id]/gateways/[serial]/devices/[device]/features/someprop/doaction', '{"name": "abc"}')
def test_setProperty_string(self):
self.service.setProperty("someprop", "doaction", '{}')
self.oauth_mock.post.assert_called_once_with(
'/equipment/installations/[id]/gateways/[serial]/devices/[device]/features/someprop/doaction', '{}')