/usr/lib/python2.7/dist-packages/dicom/test/test_UID.py is in python-dicom 0.9.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # test_UID.py
"""Test suite for UID.py"""
# Copyright (c) 2008-2012 Darcy Mason
# This file is part of pydicom, released under a modified MIT license.
# See the file license.txt included with this distribution, also
# available at http://pydicom.googlecode.com
import unittest
from dicom.UID import UID, generate_uid, pydicom_root_UID, InvalidUID
class UIDtests(unittest.TestCase):
def testKnownUID(self):
"""UID: Known UID properties accessed....................."""
msg = "UID: expected '{1:s}', got '{2:s}' for UID {0:s}"
uid = UID('1.2.840.10008.1.2') # Implicit VR Little Endian
expected = 'Implicit VR Little Endian'
got = uid.name
self.assertEqual(got, expected, msg.format("name", expected, got))
expected = 'Transfer Syntax'
got = uid.type
self.assertEqual(got, expected, msg.format("type", expected, got))
expected = 'Default Transfer Syntax for DICOM'
got = uid.info
self.assertEqual(got, expected, msg.format("info", expected, got))
expected = False
got = uid.is_retired
self.assertEqual(got, expected,
msg.format("is_retired", str(expected), str(got)))
def testComparison(self):
"""UID: can compare by number or by name.................."""
uid = UID('1.2.840.10008.1.2')
self.assertEqual(uid, 'Implicit VR Little Endian',
"UID equality failed on name")
self.assertEqual(uid, '1.2.840.10008.1.2',
"UID equality failed on number string")
def testCompareNumber(self):
"""UID: comparing against a number give False............."""
# From issue 96
uid = UID('1.2.3')
self.assertNotEqual(uid, 3, "Comparison to a number returned True")
def testCompareNotEqualByName(self):
"""UID: comparing not equal by name......................."""
# from Issue 121
ct_image_storage = UID('1.2.840.10008.5.1.4.1.1.2')
msg = "UID not equal comparison by name was not correct"
self.assertFalse(ct_image_storage != 'CT Image Storage', msg)
def testCompareNone(self):
"""UID: comparing against None give False................."""
# From issue 96
uid = UID('1.2.3')
self.assertNotEqual(uid, None, "Comparison to a number returned True")
def testTransferSyntaxes(self):
pass
def testGenerateUID(self):
'''
Test UID generator
'''
# Test standard UID generation with pydicom prefix
uid = generate_uid()
self.assertEqual(uid[:26], pydicom_root_UID)
# Test standard UID generation with no prefix
uid = generate_uid(None)
self.assertEqual(uid[:5], '2.25.')
# Test invalid UID truncation (trailing dot)
invalid_prefix = \
'1.2.33333333333333333333333333333333333333333333333333333333333.333.'
self.assertRaises(InvalidUID,
lambda: generate_uid(prefix=invalid_prefix, truncate=True))
# Test standard UID with truncate=True
prefix = '1.2.3.444444'
uid = generate_uid(prefix=prefix, truncate=True)
self.assertEqual(uid[:12], prefix)
if __name__ == "__main__":
unittest.main()
|