""" open/dulcinea/lib/property/test/utest_property_list.py """ from dulcinea.common import CommonTest from dulcinea.property import get_property_db from dulcinea.property.property import Property from dulcinea.property.property_list import PropertyList from dulcinea.property.property_template import MasterTemplate from dulcinea.property.property_type import PropertyType from dulcinea.physical_value import PhysicalValue from sancho.utest import raises class TestPropertyList (CommonTest): def _pre(self): CommonTest._pre(self) if get_property_db() is None: return get_type = get_property_db().get_property_type self.int_type = get_type(PropertyType.ATOMIC, PropertyType.INT) sec = PhysicalValue(1, 's').unit self.pv_type = get_type(PropertyType.ATOMIC, PropertyType.PHYSICAL_VALUE, element_sub_type=sec) um = PhysicalValue(1, 'um').unit self.pv_um_type = get_type(PropertyType.ATOMIC, PropertyType.PHYSICAL_VALUE, element_sub_type=um) self.str_list_type = get_type(PropertyType.LIST, PropertyType.STRING) self.str_int_table_type = get_type(PropertyType.TABLE, PropertyType.INT, key_type=PropertyType.STRING) def check_basic(self): if get_property_db() is None: return template = MasterTemplate('downtime', self.pv_type) property = template.create_value() PropertyList([property]) PropertyList([template]) PropertyList([property]) PropertyList([template]) raises(TypeError, PropertyList, [property, object()]) def check_filtering(self): if get_property_db() is None: return template = MasterTemplate("a", self.int_type) property = Property(MasterTemplate("b", self.pv_type)) plist = PropertyList([template, property]) assert list(plist.get_value_properties()) == [property] assert list(plist.get_templates()) == [template] assert list(plist.get_visible()) == [template, property] assert list(plist + []) == list(plist) if __name__ == "__main__": TestPropertyList()