def test_assignment_and_exceptions(self): """ Check incorrect types/values for properties raise exceptions """ primitive = SOPClassExtendedNegotiation() ## Check assignment # SOP Class UID reference_uid = UID('1.2.840.10008.5.1.4.1.1.2') primitive.sop_class_uid = b'1.2.840.10008.5.1.4.1.1.2' assert primitive.sop_class_uid == reference_uid primitive.sop_class_uid = '1.2.840.10008.5.1.4.1.1.2' assert primitive.sop_class_uid == reference_uid primitive.sop_class_uid = UID('1.2.840.10008.5.1.4.1.1.2') assert primitive.sop_class_uid == reference_uid # Service Class Application Information primitive.service_class_application_information = ( b'\x02\x00\x03\x00\x01\x00') assert primitive.service_class_application_information == ( b'\x02\x00\x03\x00\x01\x00') ## Check exceptions # SOP Class UID with pytest.raises(TypeError): primitive.sop_class_uid = 10 with pytest.raises(TypeError): primitive.sop_class_uid = 45.2 with pytest.raises(ValueError): primitive.sop_class_uid = 'abc' # Service Class Application Information with pytest.raises(TypeError): primitive.service_class_application_information = 10 with pytest.raises(TypeError): primitive.service_class_application_information = 45.2 # Python 2 compatibility all bytes are str #with pytest.raises(TypeError): # primitive.service_class_application_information = 'abc' # No value set primitive = SOPClassExtendedNegotiation() with pytest.raises(ValueError): item = primitive.from_primitive() primitive.sop_class_uid = b'1.2.840.10008.5.1.4.1.1.2' with pytest.raises(ValueError): item = primitive.from_primitive() primitive = SOPClassExtendedNegotiation() primitive.service_class_application_information = ( b'\x02\x00\x03\x00\x01\x00') with pytest.raises(ValueError): item = primitive.from_primitive()
def test_assignment_and_exceptions(self): """Check incorrect types/values for properties raise exceptions""" primitive = SOPClassExtendedNegotiation() ## Check assignment # SOP Class UID reference_uid = UID("1.2.840.10008.5.1.4.1.1.2") primitive.sop_class_uid = None assert primitive.sop_class_uid is None primitive.sop_class_uid = b"1.2.840.10008.5.1.4.1.1.2" assert primitive.sop_class_uid == reference_uid primitive.sop_class_uid = "1.2.840.10008.5.1.4.1.1.2" assert primitive.sop_class_uid == reference_uid primitive.sop_class_uid = UID("1.2.840.10008.5.1.4.1.1.2") assert primitive.sop_class_uid == reference_uid # Service Class Application Information primitive.service_class_application_information = None assert primitive.service_class_application_information is None primitive.service_class_application_information = b"\x02\x00\x03\x00\x01\x00" assert primitive.service_class_application_information == ( b"\x02\x00\x03\x00\x01\x00" ) ## Check exceptions # SOP Class UID with pytest.raises(TypeError): primitive.sop_class_uid = 10 with pytest.raises(TypeError): primitive.sop_class_uid = 45.2 # Service Class Application Information with pytest.raises(TypeError): primitive.service_class_application_information = 10 with pytest.raises(TypeError): primitive.service_class_application_information = 45.2 # No value set primitive = SOPClassExtendedNegotiation() with pytest.raises(ValueError): item = primitive.from_primitive() primitive.sop_class_uid = b"1.2.840.10008.5.1.4.1.1.2" with pytest.raises(ValueError): item = primitive.from_primitive() primitive = SOPClassExtendedNegotiation() primitive.service_class_application_information = b"\x02\x00\x03\x00\x01\x00" with pytest.raises(ValueError): item = primitive.from_primitive()
def test_conversion(self): """ Check converting to PDU item works correctly """ primitive = SOPClassExtendedNegotiation() primitive.sop_class_uid = b'1.2.840.10008.5.1.4.1.1.2' primitive.service_class_application_information = ( b'\x02\x00\x03\x00\x01\x00') item = primitive.from_primitive() assert item.encode() == ( b'\x56\x00\x00\x21\x00\x19\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30' b'\x30\x30\x38\x2e\x35\x2e\x31\x2e\x34\x2e\x31\x2e\x31\x2e\x32' b'\x02\x00\x03\x00\x01\x00')