Skip to content

Commit

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


class TestDatabaseCreation(unittest.TestCase):
"""Basic test for Database loading data from scratch using the API."""
@classmethod
def setUpClass(self):
self.api = FakeAPI('data')

def test_creation(self):
"""Create a new Database and fill it with items using (Fake)API.
Basically checks whether a new instance has as many items in it as the API
says there are available, and whether these items are actually instances of
the Item class.
"""
db = database.Database(
itemtype='Movie',
api=self.api,
callback=lambda x: x,
)
db.hardUpdate()
known_count, _ = self.api.getNumOf('Movie')
self.assertEqual(len(db.items), known_count)
self.assertIsInstance(db.items[0], containers.Item)


class TestDatabaseSerialization(unittest.TestCase):
"""Test Database serialization and deserialization.
Expand Down

0 comments on commit 6fe9d55

Please sign in to comment.