Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add ESDL XML reader #226

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.4.0"
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Expand Down
71 changes: 70 additions & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export create_parameters_and_sets_from_file,
create_graph, save_solution_to_file, compute_rp_partitions
create_graph, save_solution_to_file, compute_rp_partitions, read_esdl, read_esdl_assets

using EzXML

"""
parameters, sets = create_parameters_and_sets_from_file(input_folder)
Expand Down Expand Up @@ -372,3 +374,70 @@

return rp_partitions
end

"""
read_esdl(file_path; instance_name)

Read an ESDL file to construct the flow graph and link the related
assets and flows from the specification

An ESDL file can contain multiple instances. If multiple instances
are present in the file, a specific instance has to be selected.
"""
function read_esdl(file_path; instance_name = nothing)
esdl_assets = read_esdl_assets(file_path; instance_name = instance_name)

Check warning on line 388 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L387-L388

Added lines #L387 - L388 were not covered by tests

# Gather all in-ports
id_to_index = Dict{String,Int}()
for (to_id, asset) in enumerate(esdl_assets)
for port in eachelement(asset)
if port.name != "port" || port["xsi:type"] != "esdl:InPort"
continue

Check warning on line 395 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L391-L395

Added lines #L391 - L395 were not covered by tests
end
id_to_index[port["id"]] = to_id
end
end

Check warning on line 399 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L397-L399

Added lines #L397 - L399 were not covered by tests

# Create graph based on out-ports and previously gathered in-ports
graph = Graphs.DiGraph(length(esdl_assets))
for (from_id, asset) in enumerate(esdl_assets)
for port in eachelement(asset)
if port.name != "port" || port["xsi:type"] != "esdl:OutPort"
continue

Check warning on line 406 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L402-L406

Added lines #L402 - L406 were not covered by tests
end
flows = eachsplit(port["connectedTo"], " ")
for flow in flows
if !haskey(id_to_index, flow)

Check warning on line 410 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L408-L410

Added lines #L408 - L410 were not covered by tests
# throw(ErrorException("No InPort with id '$flow' was found"))
println("No InPort with id '$flow' was found, ignoring...")
continue

Check warning on line 413 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L412-L413

Added lines #L412 - L413 were not covered by tests
end
to_id = id_to_index[flow]
Graphs.add_edge!(graph, from_id, to_id)
end
end
end

Check warning on line 419 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L415-L419

Added lines #L415 - L419 were not covered by tests

return graph

Check warning on line 421 in src/io.jl

View check run for this annotation

Codecov / codecov/patch

src/io.jl#L421

Added line #L421 was not covered by tests
end

function read_esdl_assets(file_path; instance_name = nothing)
doc = readxml(file_path)
doc_root = root(doc)
if countelements(doc_root) == 0 || firstelement(doc_root).name != "instance"
throw(ErrorException("no instance was found in given ESDL file"))
elseif isnothing(instance_name)
if countelements(doc_root) > 1
throw(
ErrorException(
"multiple instances found in file, but no instance_name was given",
),
)
else
instance_name = firstelement(doc_root)["name"]
end
end

# Use XPath expression to find all assets under the instance with name `instance_name`
return findall("//instance[@name='$instance_name']//asset", doc)
end
8 changes: 8 additions & 0 deletions test/esdl/no_instance.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--A malformed ESDL file that does not have an instance-->
<esdl:EnergySystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esdl="http://www.tno.nl/esdl" name="Norse Mythology" id="d4643afe-3813-4981-8fcf-974ca7018b5b" description="" esdlVersion="v2303" version="6">
<area xsi:type="esdl:Area" id="83dfdeaf-f885-462a-ac24-d3d3118c8f15" name="Iceland">
<area xsi:type="esdl:Area" id="3c9f292f-d7a8-4f0b-b5a8-0b17dc6ca49e" name="Asgard">
</area>
</area>
</esdl:EnergySystem>
49 changes: 49 additions & 0 deletions test/esdl/one_instance.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--An ESDL file with a single instance named "Main", containing 5 + (3) = 8 assets.-->
<esdl:EnergySystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esdl="http://www.tno.nl/esdl" name="Norse Mythology" id="d4643afe-3813-4981-8fcf-974ca7018b5b" description="" esdlVersion="v2303" version="6">
<instance xsi:type="esdl:Instance" id="ad7d4261-f4f7-4c63-8935-8e26ebf09b2f" name="Main">
<area xsi:type="esdl:Area" id="83dfdeaf-f885-462a-ac24-d3d3118c8f15" name="Iceland">
<asset xsi:type="esdl:Export" name="Export_06ca" id="06ca24ec-77f5-44fe-be5a-bf2a059e8654">
<geometry xsi:type="esdl:Point" lat="64.23429914733688" lon="-20.901145935058597"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="29ce99fd-0c4f-47ae-8e29-ab6c4041a400"/>
</asset>
<asset xsi:type="esdl:Electrolyzer" name="Electrolyzer_41ac" id="41ac619a-f1c5-4d89-a6f7-e75a9783c189">
<geometry xsi:type="esdl:Point" lat="64.2198191095311" lon="-20.953330993652347"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2 f4e1f65a-98bd-482c-8fd1-56cd70d4b515" name="In" id="a439cb30-d40f-498b-b6a7-e0cfcbda0752"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="a439cb30-d40f-498b-b6a7-e0cfcbda0752 509306f7-dd17-4597-8166-b7f8fa8854d0" id="f4e1f65a-98bd-482c-8fd1-56cd70d4b515"/>
</asset>
<asset xsi:type="esdl:GasStorage" name="GasStorage_f713" id="f7138a43-41d8-4fa7-9504-ed340bc5205e">
<geometry xsi:type="esdl:Point" lat="64.21683259218487" lon="-20.99349975585938"/>
<port xsi:type="esdl:InPort" connectedTo="8a8f5c5c-3556-4a51-81db-0f2f74eb8dc0" name="In" id="584e6bd3-36ac-4540-b7d1-c6280785b9b9"/>
</asset>
<asset xsi:type="esdl:HeatPump" name="HeatPump_4b33" id="4b33f488-b157-411a-ab02-7a0d43c154a3">
<geometry xsi:type="esdl:Point" lat="64.22728399302186" lon="-20.88912963867188"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="2f90ec2a-9efc-4979-9d86-99202db07c29"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="08332a70-84ef-43bb-8619-a1805dd8a52f" id="bb1b80cd-bce7-467d-8e86-b8b0e8644ee6"/>
<port xsi:type="esdl:InPort" connectedTo="db89cb60-8609-4417-bdbe-a7704a734176" name="Waste heat inport" id="82d42ef9-7d32-4991-821c-62b03a751ccf"/>
</asset>
<asset xsi:type="esdl:FuelCell" name="FuelCell_9121" id="91218656-3706-403a-909c-f67d14f8b40c">
<geometry xsi:type="esdl:Point" lat="64.20667602226591" lon="-20.916252136230472"/>
<port xsi:type="esdl:InPort" connectedTo="8a8f5c5c-3556-4a51-81db-0f2f74eb8dc0" name="In" id="27e984b8-7414-46c7-9f73-5f089a3c7719"/>
<port xsi:type="esdl:OutPort" name="E Out" connectedTo="5e71413e-6c3c-491f-9aef-f7702dffc477" id="a02d8cc6-ea45-4bfe-91c0-1813995c5f34"/>
<port xsi:type="esdl:OutPort" name="H Out" connectedTo="08332a70-84ef-43bb-8619-a1805dd8a52f" id="33e09eff-3a6f-4ba0-aa52-7d3595aef6f8"/>
</asset>
<area xsi:type="esdl:Area" id="dd27f13b-6d1e-4532-9092-bf5240099570" name="Valhalla">
<asset xsi:type="esdl:PVInstallation" name="PVInstallation_e36d" id="e36d17db-241b-4385-b479-b5e62eae095d">
<geometry xsi:type="esdl:Point" lat="64.28737746326682" lon="-21.061477661132816"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="efd5ad97-7b65-4acc-8bfc-44fb181daa84 f937380b-3ab1-4e57-b30d-65d90f5b2d4d" id="9bd4851c-7b05-46eb-ae42-21eccc3b17f9"/>
</asset>
<asset xsi:type="esdl:ElectricityDemand" name="ElectricityDemand_928f" id="928f1a33-549d-4e45-86aa-bb2258458a67">
<geometry xsi:type="esdl:Point" lat="64.26815581064805" lon="-21.054267883300785"/>
<port xsi:type="esdl:InPort" connectedTo="b7b65117-a9fd-4fe9-934d-1626a9939cfe 9bd4851c-7b05-46eb-ae42-21eccc3b17f9" name="In" id="efd5ad97-7b65-4acc-8bfc-44fb181daa84"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96 5e71413e-6c3c-491f-9aef-f7702dffc477 f937380b-3ab1-4e57-b30d-65d90f5b2d4d" id="eff6f16f-5544-4889-b51a-829a09acba13"/>
</asset>
<asset xsi:type="esdl:PowerPlant" type="COMBINED_CYCLE_GAS_TURBINE" name="PowerPlant_4e99" id="4e9941cd-3e92-4b52-bc66-5ca5e50ec16a">
<geometry xsi:type="esdl:Point" lat="64.26547265526776" lon="-21.087913513183597"/>
<port xsi:type="esdl:InPort" connectedTo="eeace68b-c6b6-498b-9980-356b6243e122" name="In" id="9b1b3014-be88-4e51-85d7-479a6ed2a42c"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="efd5ad97-7b65-4acc-8bfc-44fb181daa84" id="b7b65117-a9fd-4fe9-934d-1626a9939cfe"/>
</asset>
</area>
</area>
</instance>
</esdl:EnergySystem>
92 changes: 92 additions & 0 deletions test/esdl/two_instances.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--An ESDL file with two instances -->
<!--The first instance is named "Flat" has 4 assets directly under the first area-->
<!--The second instance is named "Nested" has nested areas containing (4) + (6) = 10 assets-->
<esdl:EnergySystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esdl="http://www.tno.nl/esdl" name="Norse Mythology" id="d4643afe-3813-4981-8fcf-974ca7018b5b" description="" esdlVersion="v2303" version="6">
<instance xsi:type="esdl:Instance" id="ad7d4261-f4f7-4c63-8935-8e26ebf09b2f" name="Flat">
<area xsi:type="esdl:Area" id="83dfdeaf-f885-462a-ac24-d3d3118c8f15" name="Iceland">
<asset xsi:type="esdl:Export" name="Export_06ca" id="06ca24ec-77f5-44fe-be5a-bf2a059e8654">
<geometry xsi:type="esdl:Point" lat="64.23429914733688" lon="-20.901145935058597"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="29ce99fd-0c4f-47ae-8e29-ab6c4041a400"/>
</asset>
<asset xsi:type="esdl:Electrolyzer" name="Electrolyzer_41ac" id="41ac619a-f1c5-4d89-a6f7-e75a9783c189">
<geometry xsi:type="esdl:Point" lat="64.2198191095311" lon="-20.953330993652347"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2 f4e1f65a-98bd-482c-8fd1-56cd70d4b515" name="In" id="a439cb30-d40f-498b-b6a7-e0cfcbda0752"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="a439cb30-d40f-498b-b6a7-e0cfcbda0752 509306f7-dd17-4597-8166-b7f8fa8854d0" id="f4e1f65a-98bd-482c-8fd1-56cd70d4b515"/>
</asset>
<asset xsi:type="esdl:GasStorage" name="GasStorage_f713" id="f7138a43-41d8-4fa7-9504-ed340bc5205e">
<geometry xsi:type="esdl:Point" lat="64.21683259218487" lon="-20.99349975585938"/>
<port xsi:type="esdl:InPort" connectedTo="8a8f5c5c-3556-4a51-81db-0f2f74eb8dc0" name="In" id="584e6bd3-36ac-4540-b7d1-c6280785b9b9"/>
</asset>
<asset xsi:type="esdl:HeatPump" name="HeatPump_4b33" id="4b33f488-b157-411a-ab02-7a0d43c154a3">
<geometry xsi:type="esdl:Point" lat="64.22728399302186" lon="-20.88912963867188"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="2f90ec2a-9efc-4979-9d86-99202db07c29"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="08332a70-84ef-43bb-8619-a1805dd8a52f" id="bb1b80cd-bce7-467d-8e86-b8b0e8644ee6"/>
<port xsi:type="esdl:InPort" connectedTo="db89cb60-8609-4417-bdbe-a7704a734176" name="Waste heat inport" id="82d42ef9-7d32-4991-821c-62b03a751ccf"/>
</asset>
</area>
</instance>
<instance xsi:type="esdl:Instance" id="ad7d4261-f4f7-4c63-8935-8e26ebf09b2f" name="Nested">
<area xsi:type="esdl:Area" id="83dfdeaf-f885-462a-ac24-d3d3118c8f15" name="Iceland">
<area xsi:type="esdl:Area" id="3c9f292f-d7a8-4f0b-b5a8-0b17dc6ca49e" name="Asgard">
<asset xsi:type="esdl:Export" name="Export_06ca" id="06ca24ec-77f5-44fe-be5a-bf2a059e8654">
<geometry xsi:type="esdl:Point" lat="64.23429914733688" lon="-20.901145935058597"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="29ce99fd-0c4f-47ae-8e29-ab6c4041a400"/>
</asset>
<asset xsi:type="esdl:Electrolyzer" name="Electrolyzer_41ac" id="41ac619a-f1c5-4d89-a6f7-e75a9783c189">
<geometry xsi:type="esdl:Point" lat="64.2198191095311" lon="-20.953330993652347"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2 f4e1f65a-98bd-482c-8fd1-56cd70d4b515" name="In" id="a439cb30-d40f-498b-b6a7-e0cfcbda0752"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="a439cb30-d40f-498b-b6a7-e0cfcbda0752 509306f7-dd17-4597-8166-b7f8fa8854d0" id="f4e1f65a-98bd-482c-8fd1-56cd70d4b515"/>
</asset>
<asset xsi:type="esdl:GasStorage" name="GasStorage_f713" id="f7138a43-41d8-4fa7-9504-ed340bc5205e">
<geometry xsi:type="esdl:Point" lat="64.21683259218487" lon="-20.99349975585938"/>
<port xsi:type="esdl:InPort" connectedTo="8a8f5c5c-3556-4a51-81db-0f2f74eb8dc0" name="In" id="584e6bd3-36ac-4540-b7d1-c6280785b9b9"/>
</asset>
<asset xsi:type="esdl:HeatPump" name="HeatPump_4b33" id="4b33f488-b157-411a-ab02-7a0d43c154a3">
<geometry xsi:type="esdl:Point" lat="64.22728399302186" lon="-20.88912963867188"/>
<port xsi:type="esdl:InPort" connectedTo="dc76a962-0359-4f88-9774-054c81aa78f2" name="In" id="2f90ec2a-9efc-4979-9d86-99202db07c29"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="08332a70-84ef-43bb-8619-a1805dd8a52f" id="bb1b80cd-bce7-467d-8e86-b8b0e8644ee6"/>
<port xsi:type="esdl:InPort" connectedTo="db89cb60-8609-4417-bdbe-a7704a734176" name="Waste heat inport" id="82d42ef9-7d32-4991-821c-62b03a751ccf"/>
</asset>
</area>
<area xsi:type="esdl:Area" id="befa140e-ae38-4ac9-97c5-09376be5bbad" name="Midgard">
<geometry xsi:type="esdl:Polygon" CRS="WGS84">
<exterior xsi:type="esdl:SubPolygon">
<point xsi:type="esdl:Point" lat="64.26905013784292" lon="-20.931015014648438"/>
<point xsi:type="esdl:Point" lat="64.29690882007257" lon="-20.946121215820316"/>
<point xsi:type="esdl:Point" lat="64.30941372865048" lon="-20.85617065429688"/>
<point xsi:type="esdl:Point" lat="64.29854669036891" lon="-20.78922271728516"/>
<point xsi:type="esdl:Point" lat="64.26636706936117" lon="-20.80020904541016"/>
</exterior>
</geometry>
<asset xsi:type="esdl:WindTurbine" name="WindTurbine_6cb4" id="6cb408e6-ab0c-4d1e-91e8-497a9c1bb21c">
<geometry xsi:type="esdl:Point" lat="64.294526289623" lon="-20.895996093750004"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96" id="78aa04bd-6e64-40f3-86b2-bab87cf3936e"/>
</asset>
<asset xsi:type="esdl:Import" name="Import_56bb" id="56bba6e3-29ae-4b22-9005-111d03d240db">
<geometry xsi:type="esdl:Point" lat="64.28231259027915" lon="-20.863037109375004"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96" id="6a09f018-deea-49c1-94dc-557a5afec0c4"/>
</asset>
<asset xsi:type="esdl:PumpedHydroPower" name="PumpedHydroPower_eabf" id="eabff8a3-a0bc-42da-a9c4-4d094cf2391a">
<geometry xsi:type="esdl:Point" lat="64.29363278764076" lon="-20.92552185058594"/>
<port xsi:type="esdl:InPort" connectedTo="089d1dfa-abfd-4314-a9f7-e905697a19e0" name="In" id="58194ed4-51ea-4086-abef-e804d11a98c1"/>
</asset>
<asset xsi:type="esdl:ElectricityDemand" name="ElectricityDemand_1e9e" id="1e9ec4ee-e457-4c3c-9957-a4700498bb46">
<geometry xsi:type="esdl:Point" lat="64.27754480168016" lon="-20.899085998535156"/>
<port xsi:type="esdl:InPort" connectedTo="78aa04bd-6e64-40f3-86b2-bab87cf3936e f0433555-3e3c-4650-83fb-1bdb8e291e86 e2593ac4-78be-431d-b420-1207d7d67ca1 6a09f018-deea-49c1-94dc-557a5afec0c4 eff6f16f-5544-4889-b51a-829a09acba13" name="In" id="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="58194ed4-51ea-4086-abef-e804d11a98c1 5e71413e-6c3c-491f-9aef-f7702dffc477" id="089d1dfa-abfd-4314-a9f7-e905697a19e0"/>
</asset>
<asset xsi:type="esdl:PowerPlant" type="COMBINED_CYCLE_GAS_TURBINE" name="PowerPlant_2d4c" id="2d4c5a85-6765-4c54-9de6-8722256976ff">
<geometry xsi:type="esdl:Point" lat="64.2781408202984" lon="-20.852737426757816"/>
<port xsi:type="esdl:InPort" connectedTo="eeace68b-c6b6-498b-9980-356b6243e122" name="In" id="d720f1c2-04d0-4bd6-b9a5-1fbe8d151427"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96" id="f0433555-3e3c-4650-83fb-1bdb8e291e86"/>
</asset>
<asset xsi:type="esdl:PowerPlant" type="NUCLEAR_3RD_GENERATION" name="PowerPlant_4e1c" id="4e1cd004-da90-4135-8399-fb8c56dbdcb3">
<geometry xsi:type="esdl:Point" lat="64.2918456968408" lon="-20.87608337402344" CRS="WGS84"/>
<port xsi:type="esdl:InPort" name="In" id="776a35a4-ef22-40a0-b488-94815b1b201a"/>
<port xsi:type="esdl:OutPort" name="Out" connectedTo="4d8e6f38-6ea6-41ea-a08b-25394cb0ed96" id="e2593ac4-78be-431d-b420-1207d7d67ca1"/>
</asset>
</area>
</area>
</instance>
</esdl:EnergySystem>
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Test
# Folders names
const INPUT_FOLDER = joinpath(@__DIR__, "inputs")
const OUTPUT_FOLDER = joinpath(@__DIR__, "outputs")
const ESDL_FOLDER = joinpath(@__DIR__, "esdl")

# Add run all test files in test folder
include("test-io.jl")
Expand Down
36 changes: 36 additions & 0 deletions test/test-io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,39 @@ end
@test_throws AssertionError TEM._parse_rp_partition(Val(:math), "3x4", 1:14)
end
end

@testset "ESDL parsing" begin
@testset "instance detection error handling" begin
@testset "no instance" begin
@test_throws ErrorException read_esdl_assets(
joinpath(ESDL_FOLDER, "no_instance.esdl"),
)
end

@testset "two instances" begin
@test_throws ErrorException read_esdl_assets(
joinpath(ESDL_FOLDER, "two_instances.esdl"),
)
end
end

@testset "instance asset parsing" begin
@testset "unnamed single instance" begin
assets = read_esdl_assets(joinpath(ESDL_FOLDER, "one_instance.esdl"))
@test length(assets) == 8
end

@testset "named instance out of multiple" begin
flat_assets = read_esdl_assets(
joinpath(ESDL_FOLDER, "two_instances.esdl");
instance_name = "Flat",
)
@test length(flat_assets) == 4
nested_assets = read_esdl_assets(
joinpath(ESDL_FOLDER, "two_instances.esdl");
instance_name = "Nested",
)
@test length(nested_assets) == 10
end
end
end
Loading