From 6fe9d558b47906d472649090864b49cd197566b5 Mon Sep 17 00:00:00 2001 From: Noiredd Date: Mon, 27 Apr 2020 20:41:56 +0200 Subject: [PATCH] test suite: database creation test --- test/test_database.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test_database.py b/test/test_database.py index d6db893..eafeaf5 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -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.