File: test_elements_dictionary.py

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (48 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (6)
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
import unittest

import odil

class TestElementsDictionaryKey(unittest.TestCase):
    def test_empty_constructor(self):
        key = odil.ElementsDictionaryKey()
    
    def test_tag_constructor(self):
        key = odil.ElementsDictionaryKey(odil.registry.PatientName)
    
    def test_string_constructor(self):
        key = odil.ElementsDictionaryKey("60xx0010")

class TestElementsDictionaryEntry(unittest.TestCase):
    def test_constructor(self):
        entry = odil.ElementsDictionaryEntry(
            "Patient's Name", "PatientName", "PN", "1")
        self.assertEqual(entry.name, "Patient's Name")
        self.assertEqual(entry.keyword, "PatientName")
        self.assertEqual(entry.vr, "PN")
        self.assertEqual(entry.vm, "1")

class TestElementsDictionary(unittest.TestCase):
    def test_contains(self):
        self.assertTrue(
            odil.registry.PatientName in odil.registry.public_dictionary)
        self.assertFalse(
            odil.Tag(0x0001, 0x0001) in odil.registry.public_dictionary)
        self.assertTrue("60xx0010" in odil.registry.public_dictionary)
        self.assertFalse("foo" in odil.registry.public_dictionary)
    
    def test_get_item_tag(self):
        entry = odil.registry.public_dictionary[odil.registry.PatientName]
        self.assertEqual(entry.name, "Patient's Name")
        self.assertEqual(entry.keyword, "PatientName")
        self.assertEqual(entry.vr, "PN")
        self.assertEqual(entry.vm, "1")
    
    def test_get_item_string(self):
        entry = odil.registry.public_dictionary["60xx0010"]
        self.assertEqual(entry.name, "Overlay Rows")
        self.assertEqual(entry.keyword, "OverlayRows")
        self.assertEqual(entry.vr, "US")
        self.assertEqual(entry.vm, "1")

if __name__ == "__main__":
    unittest.main()