Loading src/context/tests/test_unitary.py +26 −37 Original line number Diff line number Diff line Loading @@ -88,17 +88,16 @@ def test_delete_link_empty_uuid(context_client : ContextClient): copy_link_id['link_id']['uuid'] = '' context_client.DeleteLink(LinkId(**copy_link_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'link_id.link_id.uuid() string is empty.' msg = 'link_id.link_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_add_link_already_exists(context_client : ContextClient): # should fail with link already exists with pytest.raises(grpc._channel._InactiveRpcError) as e: context_client.AddLink(Link(**LINK)) assert e.value.code() == grpc.StatusCode.ALREADY_EXISTS msg = ' '.join([ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'already exists in the database.', ]) msg = 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) already exists in the database.' assert e.value.details() == msg def test_delete_link(context_client : ContextClient): Loading @@ -113,10 +112,7 @@ def test_delete_link_not_existing(context_client : ContextClient): with pytest.raises(grpc._channel._InactiveRpcError) as e: context_client.DeleteLink(LinkId(**LINK_ID)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.' ]) msg = 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg def test_add_link_uuid_empty(context_client : ContextClient): Loading @@ -126,7 +122,9 @@ def test_add_link_uuid_empty(context_client : ContextClient): copy_link['link_id']['link_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'link.link_id.link_id.uuid() string is empty.' msg = 'link.link_id.link_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_add_link_wrong_endpoint(context_client : ContextClient): # should fail with wrong endpoint context Loading @@ -135,11 +133,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['topoId']['contextId']['contextUuid']['uuid'] = 'wrong-context' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context) in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'mismatches acceptable Contexts({\'admin\'}).', 'Optionally, leave field empty to use predefined Context(admin).', ]) msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' assert e.value.details() == msg # should fail with wrong endpoint topology Loading @@ -148,12 +144,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['topoId']['topoId']['uuid'] = 'wrong-topo' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with device uuid is empty Loading @@ -162,7 +155,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['dev_id']['device_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].dev_id.device_id.uuid() string is empty.' msg = 'endpoint_id[#0].dev_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong endpoint device with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -170,11 +165,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['dev_id']['device_id']['uuid'] = 'wrong-device' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint uuid is empty Loading @@ -183,7 +175,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['port_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong endpoint port with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -191,11 +185,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['port_id']['uuid'] = 'wrong-port' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint device duplicated Loading @@ -204,10 +195,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][1]['dev_id']['device_id']['uuid'] = 'DEV1' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)', 'in Endpoint(#1) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1).', ]) msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1).' assert e.value.details() == msg def test_add_link(context_client : ContextClient): Loading src/device/tests/test_unitary_service.py +41 −37 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_id.device_id.uuid() string is empty.' msg = 'device.device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with device type is empty with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -73,7 +75,9 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['device_type'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_type() string is empty.' msg = 'device.device_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong device operational status with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -81,10 +85,8 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['devOperationalStatus'] = OperationalStatus.KEEP_STATE.value device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(AddDevice) does not accept OperationalStatus(KEEP_STATE).', 'Permitted values for Method(AddDevice) are OperationalStatus([\'DISABLED\', \'ENABLED\']).', ]) msg = 'Method(AddDevice) does not accept OperationalStatus(KEEP_STATE). '\ 'Permitted values for Method(AddDevice) are OperationalStatus([\'DISABLED\', \'ENABLED\']).' assert e.value.details() == msg def test_add_device_wrong_endpoint(device_client : DeviceClient): Loading @@ -95,11 +97,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): request = Device(**copy_device) device_client.AddDevice(request) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Contexts({\'admin\'}).', 'Optionally, leave field empty to use predefined Context(admin).', ]) msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' assert e.value.details() == msg # should fail with unsupported endpoint topology Loading @@ -108,11 +108,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['topoId']['topoId']['uuid'] = 'wrong-topo' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with wrong endpoint device Loading @@ -121,11 +119,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['dev_id']['device_id']['uuid'] = 'wrong-device' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Devices({\'DEV1\'}).', 'Optionally, leave field empty to use predefined Device(DEV1).', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Devices({\'DEV1\'}). '\ 'Optionally, leave field empty to use predefined Device(DEV1).' assert e.value.details() == msg # should fail with endpoint port uuid is empty Loading @@ -134,7 +130,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['port_id']['uuid'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint port type is empty with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -142,7 +140,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_type'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint[#0].port_type() string is empty.' msg = 'endpoint[#0].port_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with duplicate port in device with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -150,10 +150,8 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][1]['port_id']['port_id']['uuid'] = 'EP2' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)/Port(EP2)', 'in Endpoint(#1) of Context(admin)/Topology(admin)/Device(DEV1).', ]) msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)/Port(EP2) in Endpoint(#1) of '\ 'Context(admin)/Topology(admin)/Device(DEV1).' assert e.value.details() == msg def test_add_device(device_client : DeviceClient): Loading @@ -168,7 +166,8 @@ def test_add_device_duplicate(device_client : DeviceClient): with pytest.raises(grpc._channel._InactiveRpcError) as e: device_client.AddDevice(Device(**DEVICE)) assert e.value.code() == grpc.StatusCode.ALREADY_EXISTS assert e.value.details() == 'Context(admin)/Topology(admin)/Device(DEV1) already exists in the database.' msg = 'Context(admin)/Topology(admin)/Device(DEV1) already exists in the database.' assert e.value.details() == msg def test_delete_device_empty_uuid(device_client : DeviceClient): # should fail with device uuid is empty Loading @@ -177,7 +176,9 @@ def test_delete_device_empty_uuid(device_client : DeviceClient): copy_device_id['device_id']['uuid'] = '' device_client.DeleteDevice(DeviceId(**copy_device_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device_id.device_id.uuid() string is empty.' msg = 'device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_delete_device_not_found(device_client : DeviceClient): # should fail with device not found Loading @@ -186,7 +187,8 @@ def test_delete_device_not_found(device_client : DeviceClient): copy_device_id['device_id']['uuid'] = 'wrong-device-id' device_client.DeleteDevice(DeviceId(**copy_device_id)) assert e.value.code() == grpc.StatusCode.NOT_FOUND assert e.value.details() == 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' msg = 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' assert e.value.details() == msg def test_delete_device(device_client : DeviceClient): # should work Loading @@ -202,7 +204,9 @@ def test_configure_device_empty_device_uuid(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = '' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_id.device_id.uuid() string is empty.' msg = 'device.device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_configure_device_not_found(device_client : DeviceClient): # should fail with device not found Loading @@ -211,7 +215,8 @@ def test_configure_device_not_found(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = 'wrong-device-id' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.NOT_FOUND assert e.value.details() == 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' msg = 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' assert e.value.details() == msg def test_add_device_default_endpoint_context_topology_device(device_client : DeviceClient): # should work Loading @@ -231,7 +236,8 @@ def test_configure_device_wrong_attributes(device_client : DeviceClient): copy_device['device_type'] = 'wrong-type' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'Device(DEV1) has Type(ROADM) in the database. Cannot be changed to Type(wrong-type).' msg = 'Device(DEV1) has Type(ROADM) in the database. Cannot be changed to Type(wrong-type).' assert e.value.details() == msg # should fail with endpoints cannot be modified with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -248,10 +254,8 @@ def test_configure_device_wrong_attributes(device_client : DeviceClient): copy_device['endpointList'].clear() device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.ABORTED msg = ' '.join([ 'Any change has been requested for Device(DEV1).', 'Either specify a new configuration or a new device operational status.', ]) msg = 'Any change has been requested for Device(DEV1). '\ 'Either specify a new configuration or a new device operational status.' assert e.value.details() == msg def test_configure_device(device_client : DeviceClient): Loading src/service/tests/test_unitary.py +34 −37 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['cs_id']['contextId']['contextUuid']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service.cs_id.contextId.contextUuid.uuid() string is empty.' msg = 'service.cs_id.contextId.contextUuid.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service context does not exist Loading @@ -89,7 +90,8 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['cs_id']['cs_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service.cs_id.cs_id.uuid() string is empty.' msg = 'service.cs_id.cs_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong service type Loading @@ -98,11 +100,9 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['serviceType'] = ServiceType.UNKNOWN service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(CreateService) does not accept ServiceType(UNKNOWN).', 'Permitted values for Method(CreateService) are', 'ServiceType([\'L2NM\', \'L3NM\', \'TAPI_CONNECTIVITY_SERVICE\']).', ]) msg = 'Method(CreateService) does not accept ServiceType(UNKNOWN). '\ 'Permitted values for Method(CreateService) are '\ 'ServiceType([\'L2NM\', \'L3NM\', \'TAPI_CONNECTIVITY_SERVICE\']).' assert e.value.details() == msg # should fail with wrong service state Loading @@ -111,11 +111,9 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['serviceState']['serviceState'] = ServiceStateEnum.PENDING_REMOVAL service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(CreateService) does not accept ServiceState(PENDING_REMOVAL).', 'Permitted values for Method(CreateService) are', 'ServiceState([\'PLANNED\']).', ]) msg = 'Method(CreateService) does not accept ServiceState(PENDING_REMOVAL). '\ 'Permitted values for Method(CreateService) are '\ 'ServiceState([\'PLANNED\']).' assert e.value.details() == msg def test_create_service_wrong_constraint(service_client : ServiceClient): Loading @@ -125,7 +123,8 @@ def test_create_service_wrong_constraint(service_client : ServiceClient): copy_service['constraint'][0]['constraint_type'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'constraint[#0].constraint_type() string is empty.' msg = 'constraint[#0].constraint_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong constraint value Loading @@ -134,7 +133,8 @@ def test_create_service_wrong_constraint(service_client : ServiceClient): copy_service['constraint'][0]['constraint_value'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'constraint[#0].constraint_value() string is empty.' msg = 'constraint[#0].constraint_value() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with dupplicated constraint type Loading @@ -154,11 +154,9 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database print(copy_service) service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context) in Endpoint(#0) of Context(admin)/Service(DEV1)', 'mismatches acceptable Contexts({\'admin\'}).', msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' ]) assert e.value.details() == msg # should fail with wrong endpoint topology Loading @@ -167,11 +165,9 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['topoId']['topoId']['uuid'] = 'wrong-topo' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of Context(admin)/Service(DEV1)', 'mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with endpoint device is empty Loading @@ -180,7 +176,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['dev_id']['device_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'endpoint_id[#0].dev_id.device_id.uuid() string is empty.' msg = 'endpoint_id[#0].dev_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint device not found Loading @@ -189,10 +186,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['dev_id']['device_id']['uuid'] = 'wrong-device' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0)', 'of Context(admin)/Service(DEV1) does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint device duplicated Loading @@ -201,7 +196,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][1] = copy_service['endpointList'][0] service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of Context(admin)/Service(DEV1).' msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of '\ 'Context(admin)/Service(DEV1).' assert e.value.details() == msg # should fail with endpoint port is empty Loading @@ -210,7 +206,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['port_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint port not found Loading @@ -219,10 +216,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['port_id']['uuid'] = 'wrong-port' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0)', 'of Context(admin)/Service(DEV1) does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) does not exist in the database.' assert e.value.details() == msg def test_get_service_does_not_exist(service_client : ServiceClient): Loading Loading @@ -305,7 +300,8 @@ def test_delete_service_wrong_service_id(service_client : ServiceClient): copy_service_id['contextId']['contextUuid']['uuid'] = '' service_client.DeleteService(ServiceId(**copy_service_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service_id.contextId.contextUuid.uuid() string is empty.' msg = 'service_id.contextId.contextUuid.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service context does not exist Loading @@ -323,7 +319,8 @@ def test_delete_service_wrong_service_id(service_client : ServiceClient): copy_service_id['cs_id']['uuid'] = '' service_client.DeleteService(ServiceId(**copy_service_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service_id.cs_id.uuid() string is empty.' msg = 'service_id.cs_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service id is empty Loading Loading
src/context/tests/test_unitary.py +26 −37 Original line number Diff line number Diff line Loading @@ -88,17 +88,16 @@ def test_delete_link_empty_uuid(context_client : ContextClient): copy_link_id['link_id']['uuid'] = '' context_client.DeleteLink(LinkId(**copy_link_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'link_id.link_id.uuid() string is empty.' msg = 'link_id.link_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_add_link_already_exists(context_client : ContextClient): # should fail with link already exists with pytest.raises(grpc._channel._InactiveRpcError) as e: context_client.AddLink(Link(**LINK)) assert e.value.code() == grpc.StatusCode.ALREADY_EXISTS msg = ' '.join([ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'already exists in the database.', ]) msg = 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) already exists in the database.' assert e.value.details() == msg def test_delete_link(context_client : ContextClient): Loading @@ -113,10 +112,7 @@ def test_delete_link_not_existing(context_client : ContextClient): with pytest.raises(grpc._channel._InactiveRpcError) as e: context_client.DeleteLink(LinkId(**LINK_ID)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.' ]) msg = 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg def test_add_link_uuid_empty(context_client : ContextClient): Loading @@ -126,7 +122,9 @@ def test_add_link_uuid_empty(context_client : ContextClient): copy_link['link_id']['link_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'link.link_id.link_id.uuid() string is empty.' msg = 'link.link_id.link_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_add_link_wrong_endpoint(context_client : ContextClient): # should fail with wrong endpoint context Loading @@ -135,11 +133,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['topoId']['contextId']['contextUuid']['uuid'] = 'wrong-context' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context) in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'mismatches acceptable Contexts({\'admin\'}).', 'Optionally, leave field empty to use predefined Context(admin).', ]) msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' assert e.value.details() == msg # should fail with wrong endpoint topology Loading @@ -148,12 +144,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['topoId']['topoId']['uuid'] = 'wrong-topo' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with device uuid is empty Loading @@ -162,7 +155,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['dev_id']['device_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].dev_id.device_id.uuid() string is empty.' msg = 'endpoint_id[#0].dev_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong endpoint device with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -170,11 +165,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['dev_id']['device_id']['uuid'] = 'wrong-device' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint uuid is empty Loading @@ -183,7 +175,9 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['port_id']['uuid'] = '' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong endpoint port with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -191,11 +185,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][0]['port_id']['uuid'] = 'wrong-port' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1)', 'does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint device duplicated Loading @@ -204,10 +195,8 @@ def test_add_link_wrong_endpoint(context_client : ContextClient): copy_link['endpointList'][1]['dev_id']['device_id']['uuid'] = 'DEV1' context_client.AddLink(Link(**copy_link)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)', 'in Endpoint(#1) of Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1).', ]) msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of '\ 'Context(admin)/Topology(admin)/Link(DEV1/EP2 ==> DEV2/EP1).' assert e.value.details() == msg def test_add_link(context_client : ContextClient): Loading
src/device/tests/test_unitary_service.py +41 −37 Original line number Diff line number Diff line Loading @@ -65,7 +65,9 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_id.device_id.uuid() string is empty.' msg = 'device.device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with device type is empty with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -73,7 +75,9 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['device_type'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_type() string is empty.' msg = 'device.device_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong device operational status with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -81,10 +85,8 @@ def test_add_device_wrong_attributes(device_client : DeviceClient): copy_device['devOperationalStatus'] = OperationalStatus.KEEP_STATE.value device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(AddDevice) does not accept OperationalStatus(KEEP_STATE).', 'Permitted values for Method(AddDevice) are OperationalStatus([\'DISABLED\', \'ENABLED\']).', ]) msg = 'Method(AddDevice) does not accept OperationalStatus(KEEP_STATE). '\ 'Permitted values for Method(AddDevice) are OperationalStatus([\'DISABLED\', \'ENABLED\']).' assert e.value.details() == msg def test_add_device_wrong_endpoint(device_client : DeviceClient): Loading @@ -95,11 +97,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): request = Device(**copy_device) device_client.AddDevice(request) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Contexts({\'admin\'}).', 'Optionally, leave field empty to use predefined Context(admin).', ]) msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' assert e.value.details() == msg # should fail with unsupported endpoint topology Loading @@ -108,11 +108,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['topoId']['topoId']['uuid'] = 'wrong-topo' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with wrong endpoint device Loading @@ -121,11 +119,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['dev_id']['device_id']['uuid'] = 'wrong-device' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device)', 'in Endpoint(#0) of Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Devices({\'DEV1\'}).', 'Optionally, leave field empty to use predefined Device(DEV1).', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Topology(admin)/Device(DEV1) mismatches acceptable Devices({\'DEV1\'}). '\ 'Optionally, leave field empty to use predefined Device(DEV1).' assert e.value.details() == msg # should fail with endpoint port uuid is empty Loading @@ -134,7 +130,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_id']['port_id']['uuid'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint port type is empty with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -142,7 +140,9 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][0]['port_type'] = '' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'endpoint[#0].port_type() string is empty.' msg = 'endpoint[#0].port_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with duplicate port in device with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -150,10 +150,8 @@ def test_add_device_wrong_endpoint(device_client : DeviceClient): copy_device['endpointList'][1]['port_id']['port_id']['uuid'] = 'EP2' device_client.AddDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)/Port(EP2)', 'in Endpoint(#1) of Context(admin)/Topology(admin)/Device(DEV1).', ]) msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1)/Port(EP2) in Endpoint(#1) of '\ 'Context(admin)/Topology(admin)/Device(DEV1).' assert e.value.details() == msg def test_add_device(device_client : DeviceClient): Loading @@ -168,7 +166,8 @@ def test_add_device_duplicate(device_client : DeviceClient): with pytest.raises(grpc._channel._InactiveRpcError) as e: device_client.AddDevice(Device(**DEVICE)) assert e.value.code() == grpc.StatusCode.ALREADY_EXISTS assert e.value.details() == 'Context(admin)/Topology(admin)/Device(DEV1) already exists in the database.' msg = 'Context(admin)/Topology(admin)/Device(DEV1) already exists in the database.' assert e.value.details() == msg def test_delete_device_empty_uuid(device_client : DeviceClient): # should fail with device uuid is empty Loading @@ -177,7 +176,9 @@ def test_delete_device_empty_uuid(device_client : DeviceClient): copy_device_id['device_id']['uuid'] = '' device_client.DeleteDevice(DeviceId(**copy_device_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device_id.device_id.uuid() string is empty.' msg = 'device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_delete_device_not_found(device_client : DeviceClient): # should fail with device not found Loading @@ -186,7 +187,8 @@ def test_delete_device_not_found(device_client : DeviceClient): copy_device_id['device_id']['uuid'] = 'wrong-device-id' device_client.DeleteDevice(DeviceId(**copy_device_id)) assert e.value.code() == grpc.StatusCode.NOT_FOUND assert e.value.details() == 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' msg = 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' assert e.value.details() == msg def test_delete_device(device_client : DeviceClient): # should work Loading @@ -202,7 +204,9 @@ def test_configure_device_empty_device_uuid(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = '' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'device.device_id.device_id.uuid() string is empty.' msg = 'device.device_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg def test_configure_device_not_found(device_client : DeviceClient): # should fail with device not found Loading @@ -211,7 +215,8 @@ def test_configure_device_not_found(device_client : DeviceClient): copy_device['device_id']['device_id']['uuid'] = 'wrong-device-id' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.NOT_FOUND assert e.value.details() == 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' msg = 'Context(admin)/Topology(admin)/Device(wrong-device-id) does not exist in the database.' assert e.value.details() == msg def test_add_device_default_endpoint_context_topology_device(device_client : DeviceClient): # should work Loading @@ -231,7 +236,8 @@ def test_configure_device_wrong_attributes(device_client : DeviceClient): copy_device['device_type'] = 'wrong-type' device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT assert e.value.details() == 'Device(DEV1) has Type(ROADM) in the database. Cannot be changed to Type(wrong-type).' msg = 'Device(DEV1) has Type(ROADM) in the database. Cannot be changed to Type(wrong-type).' assert e.value.details() == msg # should fail with endpoints cannot be modified with pytest.raises(grpc._channel._InactiveRpcError) as e: Loading @@ -248,10 +254,8 @@ def test_configure_device_wrong_attributes(device_client : DeviceClient): copy_device['endpointList'].clear() device_client.ConfigureDevice(Device(**copy_device)) assert e.value.code() == grpc.StatusCode.ABORTED msg = ' '.join([ 'Any change has been requested for Device(DEV1).', 'Either specify a new configuration or a new device operational status.', ]) msg = 'Any change has been requested for Device(DEV1). '\ 'Either specify a new configuration or a new device operational status.' assert e.value.details() == msg def test_configure_device(device_client : DeviceClient): Loading
src/service/tests/test_unitary.py +34 −37 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['cs_id']['contextId']['contextUuid']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service.cs_id.contextId.contextUuid.uuid() string is empty.' msg = 'service.cs_id.contextId.contextUuid.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service context does not exist Loading @@ -89,7 +90,8 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['cs_id']['cs_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service.cs_id.cs_id.uuid() string is empty.' msg = 'service.cs_id.cs_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong service type Loading @@ -98,11 +100,9 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['serviceType'] = ServiceType.UNKNOWN service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(CreateService) does not accept ServiceType(UNKNOWN).', 'Permitted values for Method(CreateService) are', 'ServiceType([\'L2NM\', \'L3NM\', \'TAPI_CONNECTIVITY_SERVICE\']).', ]) msg = 'Method(CreateService) does not accept ServiceType(UNKNOWN). '\ 'Permitted values for Method(CreateService) are '\ 'ServiceType([\'L2NM\', \'L3NM\', \'TAPI_CONNECTIVITY_SERVICE\']).' assert e.value.details() == msg # should fail with wrong service state Loading @@ -111,11 +111,9 @@ def test_create_service_wrong_service_attributes(service_client : ServiceClient) copy_service['serviceState']['serviceState'] = ServiceStateEnum.PENDING_REMOVAL service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Method(CreateService) does not accept ServiceState(PENDING_REMOVAL).', 'Permitted values for Method(CreateService) are', 'ServiceState([\'PLANNED\']).', ]) msg = 'Method(CreateService) does not accept ServiceState(PENDING_REMOVAL). '\ 'Permitted values for Method(CreateService) are '\ 'ServiceState([\'PLANNED\']).' assert e.value.details() == msg def test_create_service_wrong_constraint(service_client : ServiceClient): Loading @@ -125,7 +123,8 @@ def test_create_service_wrong_constraint(service_client : ServiceClient): copy_service['constraint'][0]['constraint_type'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'constraint[#0].constraint_type() string is empty.' msg = 'constraint[#0].constraint_type() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with wrong constraint value Loading @@ -134,7 +133,8 @@ def test_create_service_wrong_constraint(service_client : ServiceClient): copy_service['constraint'][0]['constraint_value'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'constraint[#0].constraint_value() string is empty.' msg = 'constraint[#0].constraint_value() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with dupplicated constraint type Loading @@ -154,11 +154,9 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database print(copy_service) service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(wrong-context) in Endpoint(#0) of Context(admin)/Service(DEV1)', 'mismatches acceptable Contexts({\'admin\'}).', msg = 'Context(wrong-context) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) mismatches acceptable Contexts({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Context(admin).' ]) assert e.value.details() == msg # should fail with wrong endpoint topology Loading @@ -167,11 +165,9 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['topoId']['topoId']['uuid'] = 'wrong-topo' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = ' '.join([ 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of Context(admin)/Service(DEV1)', 'mismatches acceptable Topologies({\'admin\'}).', 'Optionally, leave field empty to use predefined Topology(admin).', ]) msg = 'Context(admin)/Topology(wrong-topo) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) mismatches acceptable Topologies({\'admin\'}). '\ 'Optionally, leave field empty to use predefined Topology(admin).' assert e.value.details() == msg # should fail with endpoint device is empty Loading @@ -180,7 +176,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['dev_id']['device_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'endpoint_id[#0].dev_id.device_id.uuid() string is empty.' msg = 'endpoint_id[#0].dev_id.device_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint device not found Loading @@ -189,10 +186,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['dev_id']['device_id']['uuid'] = 'wrong-device' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0)', 'of Context(admin)/Service(DEV1) does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(wrong-device) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) does not exist in the database.' assert e.value.details() == msg # should fail with endpoint device duplicated Loading @@ -201,7 +196,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][1] = copy_service['endpointList'][0] service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of Context(admin)/Service(DEV1).' msg = 'Duplicated Context(admin)/Topology(admin)/Device(DEV1) in Endpoint(#1) of '\ 'Context(admin)/Service(DEV1).' assert e.value.details() == msg # should fail with endpoint port is empty Loading @@ -210,7 +206,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['port_id']['uuid'] = '' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'endpoint_id[#0].port_id.uuid() string is empty.' msg = 'endpoint_id[#0].port_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with endpoint port not found Loading @@ -219,10 +216,8 @@ def test_create_service_wrong_endpoint(service_client : ServiceClient, database copy_service['endpointList'][0]['port_id']['uuid'] = 'wrong-port' service_client.CreateService(Service(**copy_service)) assert e.value.code() == grpc.StatusCode.NOT_FOUND msg = ' '.join([ 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0)', 'of Context(admin)/Service(DEV1) does not exist in the database.', ]) msg = 'Context(admin)/Topology(admin)/Device(DEV1)/Port(wrong-port) in Endpoint(#0) of '\ 'Context(admin)/Service(DEV1) does not exist in the database.' assert e.value.details() == msg def test_get_service_does_not_exist(service_client : ServiceClient): Loading Loading @@ -305,7 +300,8 @@ def test_delete_service_wrong_service_id(service_client : ServiceClient): copy_service_id['contextId']['contextUuid']['uuid'] = '' service_client.DeleteService(ServiceId(**copy_service_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service_id.contextId.contextUuid.uuid() string is empty.' msg = 'service_id.contextId.contextUuid.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service context does not exist Loading @@ -323,7 +319,8 @@ def test_delete_service_wrong_service_id(service_client : ServiceClient): copy_service_id['cs_id']['uuid'] = '' service_client.DeleteService(ServiceId(**copy_service_id)) assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT msg = 'service_id.cs_id.uuid() string is empty.' msg = 'service_id.cs_id.uuid() is out of range: '\ 'allow_empty(False) min_length(None) max_length(None) allowed_lengths(None).' assert e.value.details() == msg # should fail with service id is empty Loading