def test_delete_structured_data_with_bad_template(self): with patch('uniconfig_worker.requests.delete') as mock: mock.return_value = MockResponse( bytes(json.dumps(bad_request_response), encoding='utf-8'), 404, "") request = uniconfig_worker.delete_structured_data({ "inputData": { "device_id": "xr5", "uri": "/frinx-openconfig-interfaces:interfaces/interface=Loopback01", } }) self.assertEqual(request["status"], "FAILED") self.assertEqual(request["output"]["response_code"], 404) self.assertEqual( request["output"]["response_body"]['errors']['error'][0] ["error-type"], "protocol") self.assertEqual( request["output"]["response_body"]['errors']['error'][0] ["error-message"], "Request could not be completed because the relevant data model content does not exist" ) self.assertEqual( request["output"]["response_body"]['errors']['error'][0] ["error-tag"], "data-missing")
def delete_interface(device): url = Template(odl_url_uniconfig_ifc_config).substitute({'ifc': device.interface}) ifc_response = uniconfig_worker.delete_structured_data({'inputData': { 'device_id': device.id, 'uri': url, }}) return ifc_response
def delete_vlan(device): url = Template(odl_url_uniconfig_vlan_config).substitute( {'vlan': device.vlan}) vlan_response = uniconfig_worker.delete_structured_data( {'inputData': { 'device_id': device.id, 'uri': url, }}) return vlan_response
def device_delete_vpls(task): return uniconfig_worker.delete_structured_data({ 'inputData': { 'device_id': task['inputData']['id'], 'uri': (Template(odl_url_uniconfig_network_instance_config).substitute( {'vpls': (task['inputData']['service_id'])})), } })
def delete_interface_policy(device): if device.in_policy is None and device.out_policy is None: return url = Template(odl_url_uniconfig_ifc_policy_config).substitute({'ifc': device.interface}) ifc_response = uniconfig_worker.delete_structured_data({'inputData': { 'device_id': device.id, 'uri': url }}) return ifc_response
def test_delete_structured_data_with_device(self): with patch('uniconfig_worker.requests.delete') as mock: mock.return_value = MockResponse( bytes(json.dumps({}), encoding='utf-8'), 204, "") request = uniconfig_worker.delete_structured_data({ "inputData": { "device_id": "xr5", "uri": "/frinx-openconfig-interfaces:interfaces/interface=Loopback01" } }) self.assertEqual(request["status"], "COMPLETED") self.assertEqual(request["output"]["response_code"], 204) self.assertEqual(request["output"]["response_body"], {})