def setup(self): # Requestor presentation contexts - max 126 self.requestor_contexts = [] self.requestor_transfer_syntaxes = [ '1.2.840.10008.1.2', '1.2.840.10008.1.2.1', '1.2.840.10008.1.2.2' ] for ii, sop in enumerate(StorageSOPClassList): context = PresentationContext(ii * 2 + 1, sop.UID, [ '1.2.840.10008.1.2', '1.2.840.10008.1.2.1', '1.2.840.10008.1.2.2' ]) context.SCP = True context.SCU = True self.requestor_contexts.append(context) # Acceptor presentation contexts - no max self.acceptor_contexts = [] self.acceptor_transfer_syntaxes = [ '1.2.840.10008.1.2', '1.2.840.10008.1.2.1', '1.2.840.10008.1.2.2' ] for uid in UID_dictionary: context = PresentationContext(1, uid, [ '1.2.840.10008.1.2', '1.2.840.10008.1.2.1', '1.2.840.10008.1.2.2' ]) context.SCP = True context.SCU = False self.acceptor_contexts.append(context)
def test_equality(self): """Test presentation context equality""" pc_a = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2']) pc_b = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2']) assert pc_a == pc_a assert pc_a == pc_b assert not pc_a != pc_b assert not pc_a != pc_a pc_a.SCP = True assert not pc_a == pc_b pc_b.SCP = True assert pc_a == pc_b pc_a.SCU = True assert not pc_a == pc_b pc_b.SCU = True assert pc_a == pc_b assert not 'a' == pc_b
def test_string_output(self): """Test string output""" pc = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2']) pc.SCP = True pc.SCU = False pc.Result = 0x0002 assert '1.1.1' in pc.__str__() assert 'Implicit' in pc.__str__() assert 'Provider Rejected' in pc.__str__()
def test_scp_scu_role_negotiation(self, req, acc, out): """Test presentation service negotiation with role selection.""" # Rules! # - If the requestor doesn't ask, then there is no reply # - If the requestor is False then the reply is False # - If the requestor is True then the reply is either True or False # - If the acceptor is True then the reply is True # - If the acceptor is False then the reply is False # Note: if the requestor and acceptor can't agree then the default # roles should be used, which as we are acceptor is SCP True, SCU False rq = PresentationContext(1, '1.2.3.4', ['1.2.840.10008.1.2']) rq.SCP = req[0] rq.SCU = req[1] ac = PresentationContext(1, '1.2.3.4', ['1.2.840.10008.1.2']) ac.SCP = acc[0] ac.SCU = acc[0] result = self.test_func([rq], [ac]) assert result[0].abstract_syntax == '1.2.3.4' assert result[0].transfer_syntax[0] == '1.2.840.10008.1.2' assert result[0].SCP == out[0] assert result[0].SCU == out[1] assert result[0].result == 0x00