Пример #1
0
    def test_write_tag(self):
        string_io = BytesIO()
        stream = odil.iostream(string_io)
        writer = odil.Writer(stream, odil.registry.ExplicitVRLittleEndian)
        writer.write_tag(odil.registry.PatientID)

        self.assertEqual(string_io.getvalue(), b"\x10\x00\x20\x00")
Пример #2
0
 def test_constructor_1(self):
     stream = odil.iostream(BytesIO())
     writer = odil.Writer(stream, odil.ByteOrdering.LittleEndian, False)
     self.assertEqual(writer.byte_ordering, odil.ByteOrdering.LittleEndian)
     self.assertFalse(writer.explicit_vr)
     self.assertEqual(
         writer.item_encoding, odil.Writer.ItemEncoding.ExplicitLength)
     self.assertFalse(writer.use_group_length)
Пример #3
0
 def test_constructor_2(self):
     stream = odil.iostream(BytesIO())
     writer = odil.Writer(stream, odil.registry.ExplicitVRBigEndian_Retired)
     self.assertEqual(writer.byte_ordering, odil.ByteOrdering.BigEndian)
     self.assertTrue(writer.explicit_vr)
     self.assertEqual(writer.item_encoding,
                      odil.Writer.ItemEncoding.ExplicitLength)
     self.assertFalse(writer.use_group_length)
Пример #4
0
    def test_write_data_set(self):
        data_set = odil.DataSet()
        data_set.add("PatientName", ["Foo^Bar"])
        data_set.add("PatientID", ["FOO"])

        string_io = BytesIO()
        stream = odil.iostream(string_io)
        writer = odil.Writer(stream, odil.registry.ExplicitVRLittleEndian)
        writer.write_data_set(data_set)

        self.assertEqual(
            string_io.getvalue(),
            b"\x10\x00\x10\x00" b"PN" b"\x08\x00" b"Foo^Bar "
            b"\x10\x00\x20\x00" b"LO" b"\x04\x00" b"FOO "
        )
Пример #5
0
 def test_write_element(self):
     string_io = BytesIO()
     stream = odil.iostream(string_io)
     writer = odil.Writer(stream, odil.registry.ExplicitVRLittleEndian)
     writer.write_element(odil.Element(["Foo^Bar"], odil.VR.PN))
     self.assertEqual(string_io.getvalue(), b"PN\x08\x00Foo^Bar ")