def test_recv_assoc_ac_minimal(self, caplog): """Test minimal ACSE.debug_receive_associate_ac.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) self.acse.debug_receive_associate_ac(pdu) messages = [ "Their Implementation Class UID: 1.2.826.0.1.3680043.8.498" ".10207287587329888519122978685894984263", "Their Implementation Version Name: unknown", "Application Context Name: 1.2.840.10008.3.1.1.1", "Calling Application Name: ABCDEFGHIJKLMNOP", "Called Application Name: 1234567890123456", "Their Max PDU Receive Size: 0", "Presentation Contexts:", "Context ID: 1 (Accepted)", "Accepted Transfer Syntax: =JPEG Baseline (Process 1)", "Context ID: 3 (User Rejection)", "Context ID: 5 (Provider Rejection)", "Context ID: 7 (Abstract Syntax Not Supported)", "Context ID: 9 (Transfer Syntax Not Supported)", "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text
def test_send_assoc_ac_async(self, caplog): """Test ACSE.debug_send_associate_ac with async ops.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.ae = ae = AE() ae.add_supported_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) scp = ae.start_server(('', 11112), block=False) assoc = ae.associate('localhost', 11112) self.add_async_ops(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) evt.trigger(assoc, evt.EVT_PDU_SENT, {'pdu': pdu}) messages = [ "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation:", "Maximum Invoked Operations: 2", "Maximum Performed Operations: 3", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text assoc.release() scp.shutdown()
def test_send_assoc_ac_role(self, caplog): """Test ACSE.debug_send_associate_ac with role selection.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.ae = ae = AE() ae.add_supported_context('1.2.840.10008.1.2', scu_role=True, scp_role=True) ae.add_supported_context('1.2.840.10008.1.3', scu_role=True, scp_role=True) ae.add_supported_context('1.2.840.10008.1.4', scu_role=True, scp_role=True) ae.add_requested_context('1.2.840.10008.1.2') ae.add_requested_context('1.2.840.10008.1.3') ae.add_requested_context('1.2.840.10008.1.4') ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) scp = ae.start_server(('', 11112), block=False) ext_neg = [] ext_neg.append(build_role('1.2.840.10008.1.2', scu_role=True)) ext_neg.append(build_role('1.2.840.10008.1.3', scp_role=True)) ext_neg.append( build_role('1.2.840.10008.1.4', scu_role=True, scp_role=True)) assoc = ae.associate('localhost', 11112, ext_neg=ext_neg) self.add_scp_scu_role(self.associate_ac) contexts = self.associate_ac.presentation_context_definition_results_list for ii, cx in enumerate(contexts): cx.context_id = ii * 2 + 1 cx.result = 0 pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) evt.trigger(assoc, evt.EVT_PDU_SENT, {'pdu': pdu}) messages = [ "Abstract Syntax: =Implicit VR Little Endian", "SCP/SCU Role: SCU", "Abstract Syntax: =1.2.840.10008.1.3", "SCP/SCU Role: SCP", "Abstract Syntax: =1.2.840.10008.1.4", "SCP/SCU Role: SCP/SCU", "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text assoc.release() scp.shutdown()
def test_recv_assoc_ac_user_id(self, caplog): """Test ACSE.debug_receive_associate_ac with User Identity.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.add_user_identity_rsp(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) self.acse.debug_receive_associate_ac(pdu) messages = [ "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: Yes", ] for msg in messages: assert msg in caplog.text
def test_recv_assoc_ac_async(self, caplog): """Test ACSE.debug_receive_associate_ac with async ops.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.add_async_ops(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) self.acse.debug_receive_associate_ac(pdu) messages = [ "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation:", "Maximum Invoked Operations: 2", "Maximum Performed Operations: 3", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text
def test_send_assoc_ac_minimal(self, caplog): """Test minimal ACSE.debug_send_associate_ac.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.ae = ae = AE() ae.add_supported_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) scp = ae.start_server(('', 11112), block=False) assoc = ae.associate('localhost', 11112) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) evt.trigger(assoc, evt.EVT_PDU_SENT, {'pdu': pdu}) messages = [ "Our Implementation Class UID: 1.2.826.0.1.3680043.8.498" ".10207287587329888519122978685894984263", "Application Context Name: 1.2.840.10008.3.1.1.1", "Responding Application Name: resp. AE Title", "Our Max PDU Receive Size: 0", "Presentation Contexts:", "Context ID: 1 (Accepted)", "Abstract Syntax: =Verification SOP Class", "Accepted SCP/SCU Role: Default", "Accepted Transfer Syntax: =JPEG Baseline (Process 1)", "Context ID: 3 (User Rejection)", "Context ID: 5 (Provider Rejection)", "Context ID: 7 (Rejected - Abstract Syntax Not Supported)", "Context ID: 9 (Rejected - Transfer Syntax Not Supported)", "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text assoc.release() scp.shutdown()
def test_recv_assoc_ac_sop_ext(self, caplog): """Test ACSE.debug_receive_associate_ac with SOP Class Extended.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.add_sop_ext(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) self.acse.debug_receive_associate_ac(pdu) messages = [ "Accepted Extended Negotiation:", "SOP Class: =1.2.3.4", "[ 00 01 ]", "SOP Class: =1.2.840.10008.1.1", "[ 00 01 02 03 00 01 02 03 00 01 02 03 00 01 02" " 03", "00 01 02 03 00 01 02 03 00 01 02 03 00 01 02 03", "00 01 02 03 00 01 02 03 ]", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text
def test_recv_assoc_ac_role(self, caplog): """Test ACSE.debug_receive_associate_ac with role selection.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.add_scp_scu_role(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) self.acse.debug_receive_associate_ac(pdu) messages = [ "Accepted Role Selection:", "SOP Class: =Implicit VR Little Endian", "SCP/SCU Role: SCU", "SOP Class: =1.2.840.10008.1.3", "SCP/SCU Role: SCP", "SOP Class: =1.2.840.10008.1.4", "SCP/SCU Role: SCP/SCU", "Accepted Extended Negotiation: None", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text
def test_recv_assoc_ac_sop_ext(self, caplog): """Test ACSE.debug_receive_associate_ac with SOP Class Extended.""" with caplog.at_level(logging.DEBUG, logger='pynetdicom'): self.ae = ae = AE() ae.add_supported_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) ae.add_requested_context(VerificationSOPClass) scp = ae.start_server(('', 11112), block=False) assoc = ae.associate('localhost', 11112) self.add_sop_ext(self.associate_ac) pdu = A_ASSOCIATE_AC() pdu.from_primitive(self.associate_ac) evt.trigger(assoc, evt.EVT_PDU_RECV, {'pdu': pdu}) messages = [ "Accepted Extended Negotiation:", "SOP Class: =1.2.3.4", "00 01", "SOP Class: =1.2.840.10008.1.1", "00 01 02 03 00 01 02 03 00 01 02 03 00 01 02" " 03", "00 01 02 03 00 01 02 03 00 01 02 03 00 01 02" " 03", "00 01 02 03 00 01 02 03", "Accepted Asynchronous Operations Window Negotiation: None", "User Identity Negotiation Response: None", ] for msg in messages: assert msg in caplog.text assoc.release() scp.shutdown()