Skip to content

Commit

Permalink
FE-478: fix pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdiedrich committed Mar 4, 2024
1 parent c72ba2c commit 1b3b0c3
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions tests/test_bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class TestBills(unittest.TestCase):
# pylint: disable=protected-access

def setUp(self):
self.bills = MarketEnergyBills()
Expand All @@ -17,11 +18,11 @@ def tearDown(self):
@property
def _empty_bills(self):
return {
'bought': 0.0, 'sold': 0.0, 'spent': 0.0, 'earned': 0.0, 'total_energy': 0.0,
'total_cost': 0.0, 'market_fee': 0.0, 'type': 'Area'
"bought": 0.0, "sold": 0.0, "spent": 0.0, "earned": 0.0, "total_energy": 0.0,
"total_cost": 0.0, "market_fee": 0.0, "type": "Area"
}

def create_empty_results_with_children(self, uuid_or_name_list):
def _create_empty_results_with_children(self, uuid_or_name_list):
result_dict = {k: self._empty_bills for k in ACCUMULATED_KEYS_LIST}
result_dict.update({u: self._empty_bills for u in uuid_or_name_list})
return result_dict
Expand All @@ -41,12 +42,12 @@ def test_swap_children_uuids_to_names(self):
{"name": "house2", "uuid": house2_uuid, "parent_uuid": grid_uuid, "children": [
{"name": "pv2", "uuid": pv2_uuid, "parent_uuid": house2_uuid, "children": []},
]}
]
}
]
}
uuid_results = {
grid_uuid: self.create_empty_results_with_children([house1_uuid, house2_uuid]),
house1_uuid: self.create_empty_results_with_children([pv_uuid, load_uuid]),
house2_uuid: self.create_empty_results_with_children([pv2_uuid]),
grid_uuid: self._create_empty_results_with_children([house1_uuid, house2_uuid]),
house1_uuid: self._create_empty_results_with_children([pv_uuid, load_uuid]),
house2_uuid: self._create_empty_results_with_children([pv2_uuid]),
pv_uuid: self._empty_bills,
load_uuid: self._empty_bills,
pv2_uuid: self._empty_bills,
Expand All @@ -66,9 +67,9 @@ def test_restore_area_results_state(self):
load_uuid = str(uuid4())
pv2_uuid = str(uuid4())
name_results = {
grid_uuid: self.create_empty_results_with_children(["house1", "house2"]),
house1_uuid: self.create_empty_results_with_children(["pv", "load"]),
house2_uuid: self.create_empty_results_with_children(["pv2"]),
grid_uuid: self._create_empty_results_with_children(["house1", "house2"]),
house1_uuid: self._create_empty_results_with_children(["pv", "load"]),
house2_uuid: self._create_empty_results_with_children(["pv2"]),
pv_uuid: self._empty_bills,
load_uuid: self._empty_bills,
pv2_uuid: self._empty_bills,
Expand All @@ -81,22 +82,23 @@ def test_restore_area_results_state(self):
{"name": "house2", "uuid": house2_uuid, "parent_uuid": grid_uuid, "children": [
{"name": "pv2", "uuid": pv2_uuid, "parent_uuid": house2_uuid, "children": []},
]}
]
}
]
}

self.bills.restore_area_results_state(area_dict, name_results[grid_uuid])
assert_dicts_identical(self.bills.bills_redis_results[grid_uuid], name_results[grid_uuid])
assert_dicts_identical(self.bills.bills_results["grid"], name_results[grid_uuid])
assert_dicts_identical(self.bills.current_raw_bills[grid_uuid],
self.create_empty_results_with_children([house1_uuid, house2_uuid]))
self._create_empty_results_with_children(
[house1_uuid, house2_uuid]))

self.bills.restore_area_results_state(area_dict["children"][0],
name_results[house1_uuid])
assert_dicts_identical(self.bills.bills_redis_results[house1_uuid],
name_results[house1_uuid])
assert_dicts_identical(self.bills.bills_results["house1"], name_results[house1_uuid])
assert_dicts_identical(self.bills.current_raw_bills[house1_uuid],
self.create_empty_results_with_children([pv_uuid, load_uuid]))
self._create_empty_results_with_children([pv_uuid, load_uuid]))

self.bills.restore_area_results_state(area_dict["children"][1]["children"][0],
name_results[pv2_uuid])
Expand All @@ -119,12 +121,12 @@ def test_bills_local_format(self):
{"name": "house2", "uuid": house2_uuid, "parent_uuid": grid_uuid, "children": [
{"name": "pv2", "uuid": pv2_uuid, "parent_uuid": house2_uuid, "children": []},
]}
]
}
]
}
uuid_results = {
grid_uuid: self.create_empty_results_with_children(["house1", "house2"]),
house1_uuid: self.create_empty_results_with_children(["pv", "load"]),
house2_uuid: self.create_empty_results_with_children(["pv2"]),
grid_uuid: self._create_empty_results_with_children(["house1", "house2"]),
house1_uuid: self._create_empty_results_with_children(["pv", "load"]),
house2_uuid: self._create_empty_results_with_children(["pv2"]),
pv_uuid: self._empty_bills,
load_uuid: self._empty_bills,
pv2_uuid: self._empty_bills,
Expand All @@ -139,9 +141,9 @@ def test_bills_local_format(self):

def test_round_results_for_ui(self):
uuid_results = {
"1234": self.create_empty_results_with_children(["house1", "house2"]),
"2345": self.create_empty_results_with_children(["pv", "load"]),
"3456": self.create_empty_results_with_children(["pv2"]),
"1234": self._create_empty_results_with_children(["house1", "house2"]),
"2345": self._create_empty_results_with_children(["pv", "load"]),
"3456": self._create_empty_results_with_children(["pv2"]),
"4567": self._empty_bills,
"5678": self._empty_bills,
"6789": self._empty_bills,
Expand Down

0 comments on commit 1b3b0c3

Please sign in to comment.