Skip to content

Commit fd07da1

Browse files
authored
Merge pull request #41 from openmsa/dev/MSA-10860/ley
MSA-10860 : WP2 add 3 new fonctions : get_all_configuration_variables…
2 parents b2312fd + f5e9442 commit fd07da1

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

msa_sdk/device.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,63 @@ def get_configuration_variable(self, name: str) -> dict:
543543
self._call_get()
544544

545545
return json.loads(self.content)
546+
547+
def get_all_configuration_variables(self) -> dict:
548+
"""
549+
Get all configuration variables value.
550+
551+
Parameters
552+
----------
553+
None
554+
555+
Returns
556+
-------
557+
String: Dict() like { 'name': 'location_id', 'value': '101', 'comment': 'test'}
558+
559+
"""
560+
self.path = '/variables/{device_id}'.format(device_id=self.device_id)
561+
self._call_get()
562+
563+
return json.loads(self.content)
564+
565+
566+
def get_all_manufacturers(self) -> dict:
567+
"""
568+
Get all sorted list of manufacturers with manufacturer Id and name and models with model Id and names.
569+
570+
Parameters
571+
----------
572+
None
573+
574+
Returns
575+
-------
576+
String: Dict() like { }
577+
578+
"""
579+
self.path = '/device/v1/manufacturers'
580+
self._call_get()
581+
582+
return json.loads(self.content)
583+
584+
585+
def get_customer_id(self) -> dict:
586+
"""
587+
Get customer id /device/v1/customer/deviceId.
588+
589+
Parameters
590+
----------
591+
None
592+
593+
Returns
594+
-------
595+
String: Dict() like { }
596+
597+
"""
598+
self.path = '/device/v1/customer/{device_id}'.format(device_id=self.device_id)
599+
self._call_get()
600+
601+
return json.loads(self.content)
602+
546603

547604
def create_configuration_variable(
548605
self,

tests/test_device_get.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,54 @@ def test_execute_command_on_device(device_fixture):
362362
assert not device.fail
363363

364364
mock_call_post.assert_called_once()
365+
366+
367+
def test_get_all_configuration_variables(device_fixture): # pylint: disable=W0621
368+
"""
369+
Test get_all_configuration_variables
370+
"""
371+
device = device_fixture
372+
373+
r_value = json.dumps('{"get_all_configuration_variables": true}')
374+
375+
with patch('requests.get') as mock_call_get:
376+
mock_call_get.return_value.text = r_value
377+
378+
assert device.get_all_configuration_variables()
379+
assert device.path == '/variables/{}'.format(device.device_id)
380+
mock_call_get.assert_called_once()
381+
382+
383+
def test_get_all_manufacturers(device_fixture):
384+
"""
385+
Test get_all_manufacturers
386+
"""
387+
device = device_fixture
388+
389+
r_value = json.dumps('{"get_all_manufacturers": true}')
390+
391+
with patch('requests.get') as mock_call_get:
392+
mock_call_get.return_value.text = r_value
393+
394+
assert device.get_all_manufacturers()
395+
assert device.path == '/device/v1/manufacturers'
396+
mock_call_get.assert_called_once()
397+
398+
399+
def test_get_customer_id(device_fixture):
400+
"""
401+
Test get_customer_id
402+
"""
403+
device = device_fixture
404+
405+
r_value = json.dumps('{"get_customer_id": true}')
406+
407+
with patch('requests.get') as mock_call_get:
408+
mock_call_get.return_value.text = r_value
409+
410+
assert device.get_customer_id()
411+
assert device.path == '/device/v1/customer/{}'.format(device.device_id)
412+
mock_call_get.assert_called_once()
413+
414+
365415

0 commit comments

Comments
 (0)