-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"success": true, | ||
"usinas": { | ||
"id": 16925, | ||
"nome": "Plant Name", | ||
"inversores": [ | ||
{ | ||
"id": 21255, | ||
"nome": "Inverter Name", | ||
"descricao": "Inverter Description", | ||
"esn": "1234ABC", | ||
"situacao": 1, | ||
"tensaoca": 242, | ||
"temperatura": 80 | ||
} | ||
] | ||
}, | ||
"ultimaAtualizacao": null, | ||
"AcumuladoPotencia": "25,23 kW", | ||
"energiaGeradaHoje": "1,23 kWh", | ||
"energiaacumuladanumber": "23.20", | ||
"taxaPerformance": 1.48, | ||
"KWHporkWp": "1,2", | ||
"PerformanceRate": 0.1, | ||
"reduz_carbono_total_number": 0.012296, | ||
"economia": 12.786912 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Test sunweg.api.""" | ||
|
||
from datetime import date, datetime | ||
from os import path | ||
import os | ||
|
@@ -191,6 +192,44 @@ def test_plant_success(self) -> None: | |
assert inverter.total_energy_metric == "" | ||
assert not inverter.is_complete | ||
|
||
def test_plant_success_alt(self) -> None: | ||
"""Test plant success.""" | ||
with patch( | ||
"requests.Session.get", | ||
return_value=self.responses["plant_success_alt_response.json"], | ||
), patch("sunweg.api.APIHelper.inverter", return_value=INVERTER_MOCK): | ||
api = APIHelper("[email protected]", "password") | ||
plant = api.plant(16925) | ||
assert plant is not None | ||
assert plant.id == 16925 | ||
assert plant.name == "Plant Name" | ||
assert plant.total_power == 25.23 | ||
assert plant.last_update is None | ||
assert plant.kwh_per_kwp == 1.2 | ||
assert plant.performance_rate == 1.48 | ||
assert plant.saving == 12.786912 | ||
assert plant.today_energy == 1.23 | ||
assert plant.today_energy_metric == "kWh" | ||
assert plant.total_carbon_saving == 0.012296 | ||
assert plant.total_energy == 23.2 | ||
assert plant.__str__().startswith("<class 'sunweg.plant.Plant'>") | ||
assert len(plant.inverters) == 1 | ||
for inverter in plant.inverters: | ||
assert inverter.id == 21255 | ||
assert inverter.name == "Inverter Name" | ||
assert inverter.frequency == 0 | ||
assert inverter.power == 0.0 | ||
assert inverter.power_metric == "" | ||
assert inverter.power_factor == 0.0 | ||
assert inverter.sn == "1234ABC" | ||
assert inverter.status == Status.ERROR | ||
assert inverter.temperature == 80 | ||
assert inverter.today_energy == 0.0 | ||
assert inverter.today_energy_metric == "" | ||
assert inverter.total_energy == 0.0 | ||
assert inverter.total_energy_metric == "" | ||
assert not inverter.is_complete | ||
|
||
def test_plant_401(self) -> None: | ||
"""Test plant with expired token.""" | ||
with patch( | ||
|