コード例 #1
0
def test_GIVEN_attribute_info_WHEN_adding_attributes_THEN_attribute_object_is_created():
    key = "units"
    value = "m"
    dataset = Dataset(parent_node=None, name="ds", values=123, type=ValueTypes.INT)
    attributes = Attributes()
    attributes.set_attribute_value(key, value)
    dataset.attributes = attributes
    assert len(dataset.attributes) == 1
    assert isinstance(dataset.attributes[0], FieldAttribute)
    assert dataset.attributes[0].name == key
    assert dataset.attributes[0].values == value
コード例 #2
0
def test_GIVEN_attributes_info_WHEN_adding_attributes_THEN_attribute_objects_are_created():
    key1 = "units"
    val1 = "m"
    key2 = "testkey"
    val2 = "testval"
    dataset = Dataset(parent_node=None, name="ds", values=123, type=ValueTypes.INT)
    attributes = Attributes()
    attributes.set_attribute_value(key1, val1)
    attributes.set_attribute_value(key2, val2)
    dataset.attributes = attributes
    assert len(dataset.attributes) == 2
    assert dataset.attributes[0].name == key1
    assert dataset.attributes[0].values == val1
    assert dataset.attributes[1].name == key2
    assert dataset.attributes[1].values == val2