Skip to content

Commit

Permalink
test suite: database serialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Noiredd committed Apr 27, 2020
1 parent 52d2dc8 commit b4343a7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,37 @@ def __init__(self, removals:List[int]=[], additions:List[Tuple[int,int]]=[]):
self.additions = additions


class TestDatabaseSerialization(unittest.TestCase):
"""Test Database serialization and deserialization.
The only test in this case validates the whole serialization-deserialization
cycle, so if anything goes wrong, it will be hard to say which functionality
is actually broken.
"""
@classmethod
def setUpClass(self):
self.api = FakeAPI('data')

def test_serialization(self):
"""Serialize and deserialize a Database, check if they look the same."""
original = database.Database(
itemtype='Movie',
api=self.api,
callback=lambda x: x,
)
# Load some initial data
original.hardUpdate()
# Serialize/deserialize cycle
string = original.storeToString()
restored = database.Database.restoreFromString(
itemtype='Movie',
string=string,
api=self.api,
callback=lambda x: x,
)
self.assertEqual(original, restored)


class TestDatabaseUpdates(unittest.TestCase):
"""Test Database updates capability in different initial conditions.
Expand Down

0 comments on commit b4343a7

Please sign in to comment.