Skip to content

Commit 4509b24

Browse files
Update unit tests to check the validation works
1 parent f0fc08f commit 4509b24

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Tests/test_pvlive_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"""
66

77
import unittest
8+
from unittest.mock import MagicMock
89
from datetime import datetime, date, time
910
import pytz
1011

1112
import pandas.api.types as ptypes
12-
from pvlive_api import PVLive
13+
from pvlive_api import PVLive, PVLiveException
1314

1415
class PVLiveTestCase(unittest.TestCase):
1516
"""Tests for `pvlive.py`."""
@@ -139,6 +140,9 @@ def test_latest(self):
139140
data = self.api.latest(entity_type="gsp", entity_id=103, dataframe=True)
140141
self.check_df_columns(data)
141142
self.check_df_dtypes(data)
143+
self.api._fetch_url = MagicMock(return_value={"notdata": [], "notmeta": []})
144+
with self.assertRaises(PVLiveException):
145+
data = self.api.latest(entity_type="gsp", entity_id=0, dataframe=True)
142146

143147
def test_day_peak(self):
144148
"""Tests the day_peak function."""

pvlive_api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from pvlive_api.pvlive import PVLive
1+
from pvlive_api.pvlive import PVLive, PVLiveException
22

3-
__all__ = ["PVLive"]
3+
__all__ = ["PVLive", "PVLiveException"]

0 commit comments

Comments
 (0)