-
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
2 changed files
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,22 @@ def test_month_stats_fail(self) -> None: | |
api.month_stats_production(2013, 12, plant) | ||
assert e_info.value.__str__() == "Error message" | ||
|
||
def test_month_stats_401(self) -> None: | ||
"""Test month stats with data from server with expired token.""" | ||
with patch( | ||
"requests.Session.post", | ||
return_value=self.responses["auth_success_response.json"], | ||
), patch( | ||
"requests.Session.get", | ||
return_value=self.responses["error_401_response.txt"], | ||
): | ||
api = APIHelper("[email protected]", "password") | ||
plant = MagicMock() | ||
plant.id = 1 | ||
stats = api.month_stats_production(2023, 12, plant) | ||
assert isinstance(stats, list) | ||
assert len(stats) == 0 | ||
|
||
def test_month_stats_success(self) -> None: | ||
"""Test month stats with data from server.""" | ||
with patch( | ||
|
@@ -368,4 +384,5 @@ def test_month_stats_success(self) -> None: | |
assert stat.date == date(2023, 12, i) | ||
assert isinstance(stat.production, float) | ||
assert stat.prognostic == 98.774193548387 | ||
assert stat.__str__().startswith("<class 'sunweg.util.ProductionStats'>") | ||
i += 1 |