Skip to content

Commit

Permalink
Now all test methods can skip creating a Storage object.
Browse files Browse the repository at this point in the history
* tests/test_storage.py (TestStorage.setUp): New method.
  • Loading branch information
bje- committed Nov 21, 2024
1 parent c4ccd87 commit ec9e930
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
class TestStorage(unittest.TestCase):
"""Test Storage class."""

def setUp(self):
"""Test harness setup."""
stg = generators.Storage()

def test_initialisation(self):
"""Test constructor."""
stg = generators.Storage()
self.assertEqual(stg.series_charge, {})

def test_reset(self):
"""Test reset() method."""
stg = generators.Storage()
stg.series_charge = {0: 150}
stg.reset()
self.assertEqual(stg.series_charge, {})

def test_soc(self):
"""Test soc() method in the base class."""
stg = generators.Storage()
with self.assertRaises(NotImplementedError):
stg.soc()

def test_record(self):
"""Test record() method."""
stg = generators.Storage()
# redefine base soc() method to avoid NotImplementedError
stg.soc = lambda: 0.5
stg.record(0, 100)
Expand All @@ -49,15 +49,13 @@ def test_record(self):

def test_series(self):
"""Test series() method."""
stg = generators.Storage()
value = {0: 150}
stg.series_charge = value
series = pd.Series(value, dtype=float)
self.assertTrue(stg.series()['charge'].equals(series))

def test_store(self):
"""Test store() method."""
stg = generators.Storage()
with self.assertRaises(NotImplementedError):
stg.store(0, 100)

Expand Down

0 comments on commit ec9e930

Please sign in to comment.