Skip to content

Commit

Permalink
Update test_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Jul 8, 2024
1 parent 557ae46 commit 9b52f24
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bw2data as bd
from loguru import logger

from multifunctional.utils import add_exchange_input_if_missing, label_multifunctional_nodes
from multifunctional.utils import add_exchange_input_if_missing, label_multifunctional_nodes, update_datasets_from_allocation_results, product_as_process_name


def test_add_exchange_input_if_missing(caplog):
Expand Down Expand Up @@ -83,3 +84,31 @@ def test_label_multifunctional_nodes():
},
}
assert label_multifunctional_nodes(given) == expected


def test_product_as_process_name():
given = [
{"exchanges": [{"functional": True}, {"functional": True}]},
{"exchanges": [{"functional": True}]},
{"exchanges": [{"functional": True, "name": 'night train'}]},
{"exchanges": []},
]
expected = [
{"exchanges": [{"functional": True}, {"functional": True}]},
{"exchanges": [{"functional": True}]},
{"name": 'night train', "exchanges": [{"functional": True, "name": 'night train'}]},
{"exchanges": []},
]
product_as_process_name(given)
assert given == expected


def test_update_datasets_from_allocation_results(basic):
basic.metadata["default_allocation"] = "price"
basic.process()

ds = bd.get_node(code="my favorite code")
mf = ds.parent

assert ds
assert mf

0 comments on commit 9b52f24

Please sign in to comment.