def test_read_by_reference(mock_post): """ Read Device by reference """ mock_post.return_value.json.return_value = {'token': '12345qwert'} with patch('requests.get') as mock_call_get: mock_call_get.return_value.text = device_info() with patch('msa_sdk.msa_api.host_port') as mock_host_port: mock_host_port.return_value = ('api_hostname', '8080') device = Device() assert _is_valid_json(device.read('DEV_REF')) assert device.path == '/device/reference/DEV_REF' assert device.device_id == 21594 assert device.name == "Linux self MSA" assert device.manufacturer_id == 14020601 assert device.model_id == 14020601 assert device.management_address == '127.0.0.1' assert device.management_port == '22' assert device.management_interface == '' assert device.login == 'root' assert device.password == '$ubiqube' assert device.password_admin == '' assert not device.log_enabled assert not device.mail_alerting assert not device.reporting assert device.use_nat assert device.snmp_community == '' mock_call_get.assert_called_once()
from msa_sdk.device import Device from msa_sdk.variables import Variables context = Variables.task_call() new_device = Device(device_id=context['device_id']) new_device.read() new_device.ping(new_device.management_address) print( new_device.process_content( 'ENDED', 'Pinging IP: ' + new_device.management_address + ' successfully', context, True))