Ejemplo n.º 1
0
    def test_write_metadata_with_properties(self):
        data_type = TestObject(enum_value=3)

        # Use an ordered dict for properties so that
        # the order of properties in metadata is guaranteed
        properties = OrderedDict()
        properties["prop1"] = String("foo")
        properties["prop2"] = Int32(42)

        channel = TestObject(path="channel_path",
                             has_data=True,
                             data=[1] * 10,
                             data_type=data_type,
                             properties=properties)

        segment = TdmsSegment([channel])
        metadata = segment.metadata()

        expected_values = [
            Uint32(1),  # Number of objects
            String("channel_path"),
            Uint32(20),  # Length of raw data index in bytes
            Int32(3),  # Data type
            Uint32(1),  # Array dimension
            Uint64(10),  # Number of values
            Uint32(2),  # Number of properties
            String("prop1"),  # Property name
            Int32(0x20),
            String("foo"),
            String("prop2"),
            Int32(3),
            Int32(42),
        ]

        self.assert_sequence_equal(metadata, expected_values)
Ejemplo n.º 2
0
    def test_write_metadata_with_no_data(self):
        obj = TestObject(path="object_path", has_data=False, properties={})

        segment = TdmsSegment([obj])
        metadata = segment.metadata()

        expected_values = [
            Uint32(1),  # Number of objects
            String("object_path"),
            Bytes(b'\xFF\xFF\xFF\xFF'),  # Raw data index
            Uint32(0),  # Number of properties
        ]

        self.assert_sequence_equal(metadata, expected_values)
Ejemplo n.º 3
0
    def test_write_leadin_with_object_without_data(self):
        channel = TestObject(path="", has_data=False)

        toc = ["kTocMetaData", "kTocRawData", "kTocNewObjList"]
        metadata_size = 12

        segment = TdmsSegment([channel])
        leadin = segment.leadin(toc, metadata_size)

        expected_values = [
            Bytes(b'TDSm'),
            Int32(14),  # TOC bitmask
            Int32(4712),  # TDMS version
            Uint64(12),  # Next segment offset
            Uint64(12),  # Raw data offset
        ]

        self.assert_sequence_equal(leadin, expected_values)
Ejemplo n.º 4
0
def test_write_leadin_with_one_channel():
    data_type = StubObject(size=4)

    channel = StubObject(path="",
                         has_data=True,
                         data=[0] * 10,
                         data_type=data_type)

    toc = ["kTocMetaData", "kTocRawData", "kTocNewObjList"]
    metadata_size = 12

    segment = TdmsSegment([channel])
    leadin = segment.leadin(toc, metadata_size)

    expected_values = [
        Bytes(b'TDSm'),
        Int32(14),  # TOC bitmask
        Int32(4712),  # TDMS version
        Uint64(52),  # Next segment offset
        Uint64(12),  # Raw data offset
    ]

    _assert_sequence_equal(leadin, expected_values)