diff --git a/script.py b/script.py index 726376d..8397e5f 100644 --- a/script.py +++ b/script.py @@ -86,7 +86,7 @@ def update_reason(facility_name, buy_price, sell_price, lowest_buy_price, highes current_hour = local_time.hour # Calculate the energy required to reach full charge (in kWh) -remaining_energy_kWh = (100 - battery_soc) / 100 * battery_capacity_kWh +remaining_energy_kWh = (full_battery - battery_soc) / 100 * battery_capacity_kWh # Calculate the time required to charge the battery to full (in hours) time_to_full_charge = remaining_energy_kWh / max_charge_rate_kW diff --git a/test_script.py b/test_script.py index 9eaf25b..cb3e465 100644 --- a/test_script.py +++ b/test_script.py @@ -106,8 +106,8 @@ def test_script(self): "code": self.content, "inverter_action_id": 1, } - - + response_json = '' + try: check_code_response = requests.post(powston_api_test_code_endpoint, json=body, headers=self.header) check_code_response.raise_for_status() @@ -115,7 +115,7 @@ def test_script(self): response_json = check_code_response.json() self.assertEqual(check_code_response.status_code, 200, "Expected status code 200") self.assertIn('Success', response_json['problems'], "Expected 'Success' in problems") - self.assertTrue(response_json['status'], "Expected status to be True") + self.assertTrue(response_json['status'], f"Expected status to be True: {response_json}") except requests.RequestException as e: self.fail(f"Request failed: {str(e)}") except KeyError as e: