Exemplo 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)
Exemplo 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)