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 self.assertTrue('1.1.1' in pc.__str__()) self.assertTrue('Implicit' in pc.__str__()) self.assertTrue('Provider Rejected' in pc.__str__())
def test_status(self): """Test presentation context status""" pc = PresentationContext(1) statuses = [None, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05] results = ['Pending', 'Accepted', 'User Rejected', 'Provider Rejected', 'Abstract Syntax Not Supported', 'Transfer Syntax(es) Not Supported', 'Unknown'] for status, result in zip(statuses, results): pc.Result = status self.assertEqual(pc.status, result)
def test_property_setters(self): """Test the property setters""" # Requestor req = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2']) acc = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2.1']) # No matching abstract syntax pcm = PresentationContextManager([req]) acc = PresentationContext(1, '1.1.2', ['1.2.840.10008.1.2']) pcm.acceptor_contexts = [acc] self.assertEqual(pcm.accepted, []) acc.Result = 0x03 #print(acc, pcm.rejected) self.assertEqual(pcm.rejected, [acc]) pcm = PresentationContextManager() with self.assertRaises(RuntimeError): pcm.acceptor_contexts = [acc] pcm.requestor_contexts = [req] self.assertEqual(pcm.requestor_contexts, [req]) with self.assertRaises(TypeError): pcm.requestor_contexts = req # Acceptor # No matching transfer syntax pcm.requestor_contexts = [req] pcm.acceptor_contexts = [acc] self.assertEqual(pcm.accepted, []) acc.Result = 0x04 self.assertEqual(pcm.rejected, [acc]) # Accepted pcm = PresentationContextManager() pcm.requestor_contexts = [req] acc = PresentationContext(1, '1.1.1', ['1.2.840.10008.1.2']) pcm.acceptor_contexts = [acc] self.assertEqual(pcm.rejected, []) acc.Result = 0x01 self.assertEqual(pcm.accepted, [acc])