Skip to content

Commit

Permalink
update test data and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wingechr committed Sep 13, 2024
1 parent 37f12e2 commit 4c894c1
Show file tree
Hide file tree
Showing 9 changed files with 4,953 additions and 4,932 deletions.
144 changes: 57 additions & 87 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,24 @@ def test_example_api_call_1_ship(self):
# test result categories
res_values = res.groupby(["process_type", "cost_type"]).sum("values")["values"]
expected_result = {
("Water", "CAPEX"): 1.1342172270672746,
("Water", "OPEX"): 0.539157778349926,
("Water", "FLOW"): 1.195988210583831,
("Electrolysis", "CAPEX"): 290.29664931801034,
("Electrolysis", "OPEX"): 68.99723120650344,
("Electricity generation", "CAPEX"): 927.4434737560686,
("Electricity generation", "OPEX"): 308.606539951669,
("Transportation (Ship)", "CAPEX"): 61.35376450396558,
("Transportation (Ship)", "OPEX"): 71.15409022458118,
("Transportation (Ship)", "FLOW"): 106.24743335376925,
("Carbon", "CAPEX"): 196.81657679863747,
("Carbon", "OPEX"): 113.57351510254443,
("Carbon", "FLOW"): 100.57397108324335,
("Derivative production", "CAPEX"): 90.50895668682817,
("Derivative production", "OPEX"): 39.171320804334,
("Heat", "FLOW"): 277.3302192660863,
# ("Electricity and H2 storage", "OPEX"): 176.3817106548646,
# TODO: test data not up to date
("Carbon", "CAPEX"): 215.39641925483323,
("Carbon", "FLOW"): 113.12731315531511,
("Carbon", "OPEX"): 127.74942135397198,
("Derivative production", "CAPEX"): 99.05316664855528,
("Derivative production", "OPEX"): 44.060567834906934,
("Electricity and H2 storage", "CAPEX"): 280.77888565912076,
("Electricity and H2 storage", "OPEX"): 1.3769573769647385,
("Electricity generation", "CAPEX"): 482.2723667527405,
("Electricity generation", "OPEX"): 99.456760428662,
("Electrolysis", "CAPEX"): 467.4703221865535,
("Electrolysis", "OPEX"): 113.41671110837947,
("Heat", "FLOW"): 311.94574723890867,
("Transportation (Ship)", "CAPEX"): 67.14567135002606,
("Transportation (Ship)", "FLOW"): 119.53810876643458,
("Transportation (Ship)", "OPEX"): 80.92390973573872,
("Water", "CAPEX"): 1.2624365339946522,
("Water", "FLOW"): 1.3588564441074482,
("Water", "OPEX"): 0.6125796349979609,
}

result_dict = {k: pytest.approx(v) for k, v in res_values.items() if v}
Expand All @@ -134,20 +134,20 @@ def test_example_api_call_2_ship_own_fuel(self):
# test result categories
res_values = res.groupby(["process_type", "cost_type"]).sum("values")["values"]
expected_result = {
("Water", "CAPEX"): 0.8511210005237106,
("Water", "OPEX"): 0.21273242859187,
("Water", "FLOW"): 0.471894289243873,
("Electrolysis", "CAPEX"): 457.96199870023696,
("Electrolysis", "OPEX"): 85.8485762832237,
("Electricity generation", "CAPEX"): 838.9488831589423,
("Electricity generation", "OPEX"): 146.78305821183,
("Transportation (Ship)", "OPEX"): 12.2061245592688,
("Carbon", "FLOW"): 61.3694736856213,
("Derivative production", "CAPEX"): 188.2042202083766,
("Derivative production", "OPEX"): 37.0003810701601,
("Derivative production", "FLOW"): 16.8369286421993,
# ("Electricity and H2 storage", "OPEX"): 40.72566174247268,
# TODO: test data not up to date
("Carbon", "FLOW"): 70.62864261323912,
("Derivative production", "CAPEX"): 315.1854962423828,
("Derivative production", "FLOW"): 19.377213854990554,
("Derivative production", "OPEX"): 42.5828434596838,
("Electricity and H2 storage", "CAPEX"): 289.05606587378134,
("Electricity and H2 storage", "OPEX"): 0.5558849382145459,
("Electricity generation", "CAPEX"): 943.231485988988,
("Electricity generation", "OPEX"): 103.197961645443,
("Electrolysis", "CAPEX"): 970.5791481047149,
("Electrolysis", "OPEX"): 129.05048275062325,
("Transportation (Ship)", "OPEX"): 14.047733464451378,
("Water", "CAPEX"): 1.3949529227921325,
("Water", "FLOW"): 0.5485774963784155,
("Water", "OPEX"): 0.24730162185771912,
}

result_dict = {k: pytest.approx(v) for k, v in res_values.items() if v}
Expand All @@ -171,34 +171,20 @@ def test_example_api_call_3_pipeline_sea_land(self):
res = self._test_api_call(settings)
# test result categories
res_values = res.groupby(["process_type", "cost_type"]).sum("values")["values"]

for k, v in {
("Water", "CAPEX"): 0.09778240749517693,
("Water", "OPEX"): 0.0301895762734038,
("Water", "FLOW"): 0.0669681098101092,
("Electrolysis", "CAPEX"): 31.26888734395876,
("Electrolysis", "OPEX"): 4.827015838720482,
("Electrolysis", "FLOW"): 0,
("Electricity generation", "CAPEX"): 222.35293638860577,
("Electricity generation", "OPEX"): 58.3523144804189,
("Electricity generation", "FLOW"): 0,
("Transportation (Pipeline)", "CAPEX"): 5.312543588236488,
("Transportation (Pipeline)", "OPEX"): 24.678148029682,
("Transportation (Pipeline)", "FLOW"): 2.97636043600485,
("Transportation (Ship)", "CAPEX"): 0,
("Transportation (Ship)", "OPEX"): 0,
("Transportation (Ship)", "FLOW"): 0,
("Carbon", "CAPEX"): 0,
("Carbon", "OPEX"): 0,
("Carbon", "FLOW"): 0,
("Derivative production", "CAPEX"): 0,
("Derivative production", "OPEX"): 0,
("Derivative production", "FLOW"): 0,
("Heat", "CAPEX"): 0,
("Heat", "OPEX"): 0,
("Heat", "FLOW"): 0,
("Electricity and H2 storage", "CAPEX"): 0,
("Electricity and H2 storage", "OPEX"): 0, # TODO: testdata is outdated
("Electricity and H2 storage", "FLOW"): 0,
("Electricity and H2 storage", "CAPEX"): 45.95241145770308,
("Electricity and H2 storage", "OPEX"): 0.0,
("Electricity generation", "CAPEX"): 318.68449080388336,
("Electricity generation", "OPEX"): 55.11336801926485,
("Electrolysis", "CAPEX"): 67.95373961580324,
("Electrolysis", "OPEX"): 7.357831479534695,
("Transportation (Pipeline)", "CAPEX"): 8.71722456310389,
("Transportation (Pipeline)", "FLOW"): 3.425558822284455,
("Transportation (Pipeline)", "OPEX"): 28.402624453035553,
("Water", "CAPEX"): 0.160448792616752,
("Water", "FLOW"): 0.07707507350140025,
("Water", "OPEX"): 0.03474584868598187,
}.items():
self.assertAlmostEqual(res_values.get(k, 0), v, places=3, msg=k)

Expand All @@ -219,34 +205,18 @@ def test_example_api_call_4_pipeline_retrofitted(self):
res = self._test_api_call(settings)
# test result categories
res_values = res.groupby(["process_type", "cost_type"]).sum("values")["values"]

for k, v in {
("Water", "CAPEX"): 0,
("Water", "OPEX"): 0,
("Water", "FLOW"): 0.362589872395495,
("Electrolysis", "CAPEX"): 14.26507991048662,
("Electrolysis", "OPEX"): 3.546461787521432,
("Electrolysis", "FLOW"): 0,
("Electricity generation", "CAPEX"): 26.50698388538755,
("Electricity generation", "OPEX"): 6.58993893072181,
("Electricity generation", "FLOW"): 0,
("Transportation (Pipeline)", "CAPEX"): 1.281983377858589,
("Transportation (Pipeline)", "OPEX"): 2.55172143395481,
("Transportation (Pipeline)", "FLOW"): 0.710683430261875,
("Transportation (Ship)", "CAPEX"): 0,
("Transportation (Ship)", "OPEX"): 0,
("Transportation (Ship)", "FLOW"): 0,
("Carbon", "CAPEX"): 0,
("Carbon", "OPEX"): 0,
("Carbon", "FLOW"): 0,
("Derivative production", "CAPEX"): 0,
("Derivative production", "OPEX"): 0,
("Derivative production", "FLOW"): 0,
("Heat", "CAPEX"): 0,
("Heat", "OPEX"): 0,
("Heat", "FLOW"): 0,
("Electricity and H2 storage", "CAPEX"): 0,
("Electricity and H2 storage", "OPEX"): 0, # TODO: test data is outdated
("Electricity and H2 storage", "FLOW"): 0,
("Electricity and H2 storage", "CAPEX"): 18.462175001891314,
("Electricity and H2 storage", "OPEX"): 0.0,
("Electricity generation", "CAPEX"): 24.36897573382399,
("Electricity generation", "OPEX"): 8.4441424752989,
("Electrolysis", "CAPEX"): 21.00166954706848,
("Electrolysis", "OPEX"): 5.416729682187833,
("Transportation (Pipeline)", "CAPEX"): 1.4250719758145969,
("Transportation (Pipeline)", "FLOW"): 0.819582849362961,
("Transportation (Pipeline)", "OPEX"): 2.942726725527567,
("Water", "FLOW"): 0.4181502313322993,
}.items():
self.assertAlmostEqual(res_values.get(k, 0), v, places=3, msg=k)

Expand Down Expand Up @@ -310,7 +280,7 @@ def test_datahandler(self):
cache_dir=None,
)

expected_val = 0.0503
expected_val = 0.046

# WACC without source_region_code (this is NOT fine)
self.assertRaises(
Expand Down
Loading

0 comments on commit 4c894c1

Please sign in to comment.