Skip to content

Refine tests

Refine tests #97

Triggered via pull request September 27, 2023 09:54
@p-snftp-snft
synchronize #26
revision/tests
Status Success
Total duration 23s
Artifacts

lint.yml

on: pull_request
Run linters
12s
Run linters
Fit to window
Zoom out
Zoom in

Annotations

6 errors and 1 warning
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L21
from oemof.network.network import Bus from oemof.network.network.nodes import Node def test_entity_grouping_on_construction(): - bus = Bus(label="test bus") - ensys = es.EnergySystem(entities=[bus]) - assert ensys.groups[bus.label] is bus + bus = Bus(label="test bus") + ensys = es.EnergySystem(entities=[bus]) + assert ensys.groups[bus.label] is bus + def test_that_none_is_not_a_valid_group(): def by_uid(n): if "Not in 'Group'" in n.uid: return None else: return "Group" ensys = es.EnergySystem(groupings=[by_uid]) - ungrouped = [ - Node(uid="Not in 'Group': {}".format(i)) for i in range(10) - ] + ungrouped = [Node(uid="Not in 'Group': {}".format(i)) for i in range(10)] grouped = [Node(uid="In 'Group': {}".format(i)) for i in range(10)] assert None not in ensys.groups for g in ensys.groups.values(): for e in ungrouped: if isinstance(g, Iterable) and not isinstance(g, str): assert e not in g for e in grouped: if isinstance(g, Iterable) and not isinstance(g, str): assert e in g + def test_defining_multiple_groupings_with_one_function(): def assign_to_multiple_groups_in_one_go(n): g1 = n.label[-1] g2 = n.label[0:3]
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L75
group, len(ensy.groups[group]), sorted([e.label for e in ensy.groups[group]]), ) + def test_grouping_filter_parameter(): g1 = Grouping( key=lambda e: "The Special One", filter=lambda e: "special" in str(e), )
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L91
others = set(Node(label="other: {}".format(i)) for i in range(10)) ensys.add(special, *subset) ensys.add(*others) assert ensys.groups["The Special One"] == special assert ensys.groups["A Subset"] == subset + def test_proper_filtering(): """`Grouping.filter` should not be "all or nothing". There was a bug where, if `Grouping.filter` returned `False` only for
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L110
ensys = es.EnergySystem(groupings=[g]) special = Node(label="object") ensys.add(special) assert ensys.groups["group"] == {2, 4} + def test_non_callable_group_keys(): collect_everything = Entities(key="everything") - g1 = Grouping( - key="The Special One", filter=lambda e: "special" in e.label - ) + g1 = Grouping(key="The Special One", filter=lambda e: "special" in e.label) g2 = Entities(key="A Subset", filter=lambda e: "subset" in e.label) ensys = es.EnergySystem(groupings=[g1, g2, collect_everything]) special = Node(label="special") subset = set(Node(label="subset: {}".format(i)) for i in range(2)) others = set(Node(label="other: {}".format(i)) for i in range(2))
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L126
everything.add(special) ensys.add(*everything) assert ensys.groups["The Special One"] == special assert ensys.groups["A Subset"] == subset assert ensys.groups["everything"] == everything + def test_grouping_laziness(): """Energy system `groups` should be fully lazy. `Node`s added to an energy system should only be tested for and put
/home/runner/work/oemof-network/oemof-network/tests/test_groupings/test_groupings_basic.py#L158
group, "\n ".join(pformat(ensys.groups[group]).split("\n")), ), ) + def test_constant_group_keys(): """Callable keys passed in as `constant_key` should not be called. The `constant_key` parameter can be used to specify callable group keys without having to worry about `Grouping`s trying to call them. This
Run linters
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions/setup-python@v1, samuelmeuli/lint-action@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/