diff --git a/tests/_files/tabular_datapackage_hack_a_thon_goal/datapackage.json b/tests/_files/tabular_datapackage_hack_a_thon_goal/datapackage.json index c9e2838..d41bb2a 100644 --- a/tests/_files/tabular_datapackage_hack_a_thon_goal/datapackage.json +++ b/tests/_files/tabular_datapackage_hack_a_thon_goal/datapackage.json @@ -1,656 +1,656 @@ { - "profile": "tabular-data-package", - "resources": [ - { - "path": "data/sequences/modex_demand_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_demand_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "datetime", - "format": "default" - }, - { - "name": "bandwidth_type_BB", - "type": "string", - "format": "default" - }, - { - "name": "unknown_BB", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_BE", - "type": "string", - "format": "default" - }, - { - "name": "unknown_BE", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_BW", - "type": "string", - "format": "default" - }, - { - "name": "unknown_BW", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_BY", - "type": "string", - "format": "default" - }, - { - "name": "unknown_BY", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_HB", - "type": "string", - "format": "default" - }, - { - "name": "unknown_HB", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_HE", - "type": "string", - "format": "default" - }, - { - "name": "unknown_HE", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_HH", - "type": "string", - "format": "default" - }, - { - "name": "unknown_HH", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_MV", - "type": "string", - "format": "default" - }, - { - "name": "unknown_MV", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_NI", - "type": "string", - "format": "default" - }, - { - "name": "unknown_NI", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_NW", - "type": "string", - "format": "default" - }, - { - "name": "unknown_NW", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_RP", - "type": "string", - "format": "default" - }, - { - "name": "unknown_RP", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_SH", - "type": "string", - "format": "default" - }, - { - "name": "unknown_SH", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_SL", - "type": "string", - "format": "default" - }, - { - "name": "unknown_SL", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_SN", - "type": "string", - "format": "default" - }, - { - "name": "unknown_SN", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_ST", - "type": "string", - "format": "default" - }, - { - "name": "unknown_ST", - "type": "number", - "format": "default" - }, - { - "name": "bandwidth_type_TH", - "type": "string", - "format": "default" - }, - { - "name": "unknown_TH", - "type": "number", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] - } - }, - { - "path": "data/sequences/modex_tech_wind_turbine_onshore_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_wind_turbine_onshore_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "datetime", - "format": "default" - }, - { - "name": "onshore_BB", - "type": "number", - "format": "default" - }, - { - "name": "onshore_BE", - "type": "number", - "format": "default" - }, - { - "name": "onshore_BW", - "type": "number", - "format": "default" - }, - { - "name": "onshore_BY", - "type": "number", - "format": "default" - }, - { - "name": "onshore_Baltic", - "type": "string", - "format": "default" - }, - { - "name": "onshore_HB", - "type": "number", - "format": "default" - }, - { - "name": "onshore_HE", - "type": "number", - "format": "default" - }, - { - "name": "onshore_HH", - "type": "number", - "format": "default" - }, - { - "name": "onshore_MV", - "type": "number", - "format": "default" - }, - { - "name": "onshore_NI", - "type": "number", - "format": "default" - }, - { - "name": "onshore_NW", - "type": "number", - "format": "default" - }, - { - "name": "onshore_North", - "type": "string", - "format": "default" - }, - { - "name": "onshore_RP", - "type": "number", - "format": "default" - }, - { - "name": "onshore_SH", - "type": "number", - "format": "default" - }, - { - "name": "onshore_SL", - "type": "number", - "format": "default" - }, - { - "name": "onshore_SN", - "type": "number", - "format": "default" - }, - { - "name": "onshore_ST", - "type": "number", - "format": "default" - }, - { - "name": "onshore_TH", - "type": "number", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] - } - }, - { - "path": "data/periods/periods.csv", - "profile": "tabular-data-resource", + "profile": "tabular-data-package", + "resources": [ + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_demand_sequence", + "path": "data/sequences/modex_demand_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "datetime" + }, + { + "format": "default", + "name": "bandwidth_type_BB", + "type": "string" + }, + { + "format": "default", + "name": "unknown_BB", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_BE", + "type": "string" + }, + { + "format": "default", + "name": "unknown_BE", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_BW", + "type": "string" + }, + { + "format": "default", + "name": "unknown_BW", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_BY", + "type": "string" + }, + { + "format": "default", + "name": "unknown_BY", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_HB", + "type": "string" + }, + { + "format": "default", + "name": "unknown_HB", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_HE", + "type": "string" + }, + { + "format": "default", + "name": "unknown_HE", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_HH", + "type": "string" + }, + { + "format": "default", + "name": "unknown_HH", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_MV", + "type": "string" + }, + { + "format": "default", + "name": "unknown_MV", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_NI", + "type": "string" + }, + { + "format": "default", + "name": "unknown_NI", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_NW", + "type": "string" + }, + { + "format": "default", + "name": "unknown_NW", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_RP", + "type": "string" + }, + { + "format": "default", + "name": "unknown_RP", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_SH", + "type": "string" + }, + { + "format": "default", + "name": "unknown_SH", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_SL", + "type": "string" + }, + { + "format": "default", + "name": "unknown_SL", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_SN", + "type": "string" + }, + { + "format": "default", + "name": "unknown_SN", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_ST", + "type": "string" + }, + { + "format": "default", + "name": "unknown_ST", + "type": "number" + }, + { + "format": "default", + "name": "bandwidth_type_TH", + "type": "string" + }, + { + "format": "default", + "name": "unknown_TH", + "type": "number" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_wind_turbine_onshore_sequence", + "path": "data/sequences/modex_tech_wind_turbine_onshore_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "datetime" + }, + { + "format": "default", + "name": "onshore_BB", + "type": "number" + }, + { + "format": "default", + "name": "onshore_BE", + "type": "number" + }, + { + "format": "default", + "name": "onshore_BW", + "type": "number" + }, + { + "format": "default", + "name": "onshore_BY", + "type": "number" + }, + { + "format": "default", + "name": "onshore_Baltic", + "type": "string" + }, + { + "format": "default", + "name": "onshore_HB", + "type": "number" + }, + { + "format": "default", + "name": "onshore_HE", + "type": "number" + }, + { + "format": "default", + "name": "onshore_HH", + "type": "number" + }, + { + "format": "default", + "name": "onshore_MV", + "type": "number" + }, + { + "format": "default", + "name": "onshore_NI", + "type": "number" + }, + { + "format": "default", + "name": "onshore_NW", + "type": "number" + }, + { + "format": "default", + "name": "onshore_North", + "type": "string" + }, + { + "format": "default", + "name": "onshore_RP", + "type": "number" + }, + { + "format": "default", + "name": "onshore_SH", + "type": "number" + }, + { + "format": "default", + "name": "onshore_SL", + "type": "number" + }, + { + "format": "default", + "name": "onshore_SN", + "type": "number" + }, + { + "format": "default", + "name": "onshore_ST", + "type": "number" + }, + { + "format": "default", + "name": "onshore_TH", + "type": "number" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "periods", + "path": "data/periods/periods.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + }, + { + "format": "default", "name": "periods", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - }, - { - "name": "periods", - "type": "integer", - "format": "default" - }, - { - "name": "timeincrement", - "type": "integer", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] - } - }, - { - "path": "data/elements/bus.csv", - "profile": "tabular-data-resource", + "type": "integer" + }, + { + "format": "default", + "name": "timeincrement", + "type": "integer" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "bus", + "path": "data/elements/bus.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "balanced", + "type": "boolean" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_storage_battery", + "path": "data/elements/modex_tech_storage_battery.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "capacity", + "type": "string" + }, + { + "format": "default", + "name": "capacity_cost", + "type": "array" + }, + { + "format": "default", + "name": "capacity_potential", + "type": "string" + }, + { + "format": "default", + "name": "lifetime", + "type": "array" + }, + { + "format": "default", + "name": "fixed_costs", + "type": "number" + }, + { + "format": "default", + "name": "marginal_cost", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "invest_relation_output_capacity", + "type": "number" + }, + { + "format": "default", + "name": "inflow_conversion_factor", + "type": "array" + }, + { + "format": "default", + "name": "outflow_conversion_factor", + "type": "array" + }, + { + "format": "default", "name": "bus", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "balanced", - "type": "boolean", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [], - "primaryKey": "name" + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_storage_battery.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_storage_battery", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "capacity", - "type": "string", - "format": "default" - }, - { - "name": "capacity_cost", - "type": "array", - "format": "default" - }, - { - "name": "capacity_potential", - "type": "string", - "format": "default" - }, - { - "name": "lifetime", - "type": "array", - "format": "default" - }, - { - "name": "fixed_costs", - "type": "number", - "format": "default" - }, - { - "name": "marginal_cost", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "invest_relation_output_capacity", - "type": "number", - "format": "default" - }, - { - "name": "inflow_conversion_factor", - "type": "array", - "format": "default" - }, - { - "name": "outflow_conversion_factor", - "type": "array", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - } - ], - "primaryKey": "name" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_demand", + "path": "data/elements/modex_demand.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_demand.csv", - "profile": "tabular-data-resource", - "name": "modex_demand", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - } - ] + } + ], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_generator_gas", + "path": "data/elements/modex_tech_generator_gas.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "marginal_cost", + "type": "number" + }, + { + "format": "default", + "name": "capacity_cost", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "from_bus", + "type": "string" + }, + { + "format": "default", + "name": "to_bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "from_bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_generator_gas.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_generator_gas", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "marginal_cost", - "type": "number", - "format": "default" - }, - { - "name": "capacity_cost", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "from_bus", - "type": "string", - "format": "default" - }, - { - "name": "to_bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "from_bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "to_bus", - "reference": { - "fields": "name", - "resource": "bus" - } - } - ], - "primaryKey": "name" + }, + { + "fields": "to_bus", + "reference": { + "fields": "name", + "resource": "bus" + } + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_wind_turbine_onshore", + "path": "data/elements/modex_tech_wind_turbine_onshore.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "profile", + "type": "string" + }, + { + "format": "default", + "name": "capacity_cost", + "type": "array" + }, + { + "format": "default", + "name": "lifetime", + "type": "array" + }, + { + "format": "default", + "name": "fixed_costs", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_wind_turbine_onshore.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_wind_turbine_onshore", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "profile", - "type": "string", - "format": "default" - }, - { - "name": "capacity_cost", - "type": "array", - "format": "default" - }, - { - "name": "lifetime", - "type": "array", - "format": "default" - }, - { - "name": "fixed_costs", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "profile", - "reference": { - "resource": "modex_tech_wind_turbine_onshore_sequence" - } - } - ], - "primaryKey": "name" + }, + { + "fields": "profile", + "reference": { + "resource": "modex_tech_wind_turbine_onshore_sequence" } - } - ] -} \ No newline at end of file + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + } + ] +} diff --git a/tests/structures/structure.csv b/tests/structures/structure.csv index cbd387b..dae28c8 100644 --- a/tests/structures/structure.csv +++ b/tests/structures/structure.csv @@ -2,4 +2,3 @@ id;process;parameter;inputs;outputs 1;modex_tech_storage_battery;default;electricity; 6;modex_tech_generator_gas;default;ch4;electricity 10;modex_tech_wind_turbine_onshore;default;;electricity - diff --git a/tests/test_build_datapackage.py b/tests/test_build_datapackage.py index 7dac17d..9f09a58 100644 --- a/tests/test_build_datapackage.py +++ b/tests/test_build_datapackage.py @@ -7,7 +7,7 @@ from data_adapter.databus import download_collection from data_adapter.preprocessing import Adapter from pandas import Timestamp -from utils import PATH_TEST_FILES, PATH_TMP, check_if_csv_dirs_equal +from utils import PATH_TEST_FILES, check_if_csv_dirs_equal from data_adapter_oemof.build_datapackage import DataPackage, refactor_timeseries @@ -265,7 +265,9 @@ def test_build_tabular_datapackage_from_adapter(): dir = os.path.join(path_default, "tabular_datapackage_hack_a_thon") dta.save_datapackage_to_csv(dir) - check_if_csv_dirs_equal(dir, os.path.join(path_default, "tabular_datapackage_hack_a_thon_goal")) + check_if_csv_dirs_equal( + dir, os.path.join(path_default, "tabular_datapackage_hack_a_thon_goal") + ) # FIXME: Demand is in different Format than expected.