def test_empty_dataset_profile_whitelist_invalid_object(): _, partial = create_empty_dataset( version="16", backend=InMemory, profile_whitelist=("EquipmentProfile", "TopologyProfile", "SteadyStateHypothesisProfile")) _, full = create_empty_dataset(version="16", backend=InMemory) with pytest.raises(AttributeError): partial.DiagramObjectPoint() full.DiagramObjectPoint()
def test_multi_file_manual_profile_header(): s, m = create_empty_dataset(version="16", profile_whitelist=["EQ", "TP", "SSH"]) terminals = (m.Terminal(id=42, name="somename", phases=m.enum.PhaseCode.v.AB), m.Terminal(id=21, name="someothername", phases=m.enum.PhaseCode.v.ABC)) s.add_all(terminals) header = { "profile_header": ( "http://entsoe.eu/CIM/EquipmentCore/3/1", "http://entsoe.eu/CIM/Topology/4/1", ) } trees = serialize(s, mode="Multi", header_data=header, profile_whitelist=["EQ", "TP", "SSH"]) _str = [tostring(tree) for tree in trees] assert b"http://entsoe.eu/CIM/EquipmentCore/3/1" in _str[0] assert b"http://entsoe.eu/CIM/Topology/4/1" in _str[1] assert b"http://entsoe.eu/CIM/StateVariables/4/1" not in _str[0] assert b"http://entsoe.eu/CIM/StateVariables/4/1" not in _str[1] assert b"http://entsoe.eu/CIM/StateVariables/4/1" not in _str[2] s.close()
def test_empty_dataset_profile_whitelist_fullnames(): s, m = create_empty_dataset( version="16", profile_whitelist=["EquipmentProfile", "EquipmentBoundaryProfile"]) term = m.Terminal(id=42) s.add(term) s.commit()
def test_empty_dataset_profile_whitelist(): s, m = create_empty_dataset( version="16", profile_whitelist=("EquipmentProfile", "TopologyProfile", "SteadyStateHypothesisProfile")) term = m.Terminal(id=42) s.add(term) s.commit()
def test_empty_dataset_profile_whitelist_all_allowed(): s, m = create_empty_dataset( version="16", profile_whitelist=[ "EquipmentProfile", "TopologyProfile", "SteadyStateHypothesisProfile", "DiagramLayoutProfile", "StateVariablesProfile", "SteadyStateHypothesisProfile", "GeographicalLocationProfile", "EquipmentBoundaryProfile", "TopologyBoundaryProfile" ]) term = m.Terminal(id=42) s.add(term) s.commit()
def test_serialization_attributes(): s, m = create_empty_dataset(version="16", profile_whitelist=["EQ", "TP", "SSH"]) terminals = (m.Terminal(id=42, name="somename", phases=m.enum.PhaseCode.v.AB), m.Terminal(id=21, name="someothername", phases=m.enum.PhaseCode.v.ABC)) s.add_all(terminals) _io = export(s, "Single") teststr = b'<cim:Terminal rdf:ID="21">\n <cim:IdentifiedObject.name>someothername</cim:IdentifiedObject.name>\n <cim:Terminal.phases rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#PhaseCode.ABC"/>\n </cim:Terminal>' assert teststr in _io.getvalue() s.close()
def test_manual_profile_header(): s, m = create_empty_dataset(version="16", profile_whitelist=["EQ", "TP", "SSH"]) terminals = (m.Terminal(id=42, name="somename", phases=m.enum.PhaseCode.v.AB), m.Terminal(id=21, name="someothername", phases=m.enum.PhaseCode.v.ABC)) s.add_all(terminals) header = { "profile_header": ("http://entsoe.eu/CIM/EquipmentCore/3/1", "http://entsoe.eu/CIM/EquipmentOperation/3/1") } tree = serialize(s, mode="Single", header_data=header) _str = tostring(tree) assert b"http://entsoe.eu/CIM/EquipmentCore/3/1" in _str assert b"http://entsoe.eu/CIM/EquipmentOperation/3/1" in _str assert b"http://entsoe.eu/CIM/EquipmentShortCircuit/3/1" not in _str s.close()
def test_empty_dataset_one_profile(): with pytest.raises(KeyError): s, m = create_empty_dataset(version="16", profile_whitelist=[ "EQ", ])
def test_empty_dataset_profile_whitelist_shortnames(): s, m = create_empty_dataset(version="16", profile_whitelist=["EQ", "EQ_BD"]) term = m.Terminal(id=42) s.add(term) s.commit()
def test_empty_dataset(): s, m = create_empty_dataset(version="16") term = m.Terminal(id=42) s.add(term) s.commit()