From: Tomas Mlcoch Date: Wed, 15 May 2013 10:34:29 +0000 (+0200) Subject: tests: Better python test for sqlite module. X-Git-Tag: upstream/0.2.1~188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bce85c253524a92d1be94afc2e83edbc1a28fc25;p=services%2Fcreaterepo_c.git tests: Better python test for sqlite module. --- diff --git a/tests/python/tests/test_sqlite.py b/tests/python/tests/test_sqlite.py index 6c2b02e..414c3cb 100644 --- a/tests/python/tests/test_sqlite.py +++ b/tests/python/tests/test_sqlite.py @@ -40,16 +40,26 @@ class TestCaseSqlite(unittest.TestCase): self.assertTrue(db_oth) self.assertTrue(os.path.isfile(self.tmpdir+"/other2.db")) - # Error cases - - self.assertRaises(cr.CreaterepoCException, cr.Sqlite, self.tmpdir, cr.DB_PRIMARY) + def test_sqlite_error_cases(self): + self.assertRaises(cr.CreaterepoCError, cr.Sqlite, self.tmpdir, cr.DB_PRIMARY) self.assertRaises(ValueError, cr.Sqlite, self.tmpdir+"/foo.db", 55) - self.assertRaises(TypeError, cr.Sqlite, self.tmpdir+"/foo.db", None) - self.assertRaises(TypeError, cr.Sqlite, None, cr.DB_PRIMARY) + def test_sqlite_operations_on_closed_db(self): + pkg = cr.package_from_rpm(PKG_ARCHER_PATH) + path = os.path.join(self.tmpdir, "primary.db") + db = cr.Sqlite(path, cr.DB_PRIMARY) + self.assertTrue(db) + db.close() + + self.assertRaises(cr.CreaterepoCError, db.add_pkg, pkg) + self.assertRaises(cr.CreaterepoCError, db.dbinfo_update, "somechecksum") + + db.close() # No error shoud be raised + del db # No error shoud be raised + def test_sqlite_primary_schema(self): path = os.path.join(self.tmpdir, "primary.db") cr.PrimarySqlite(path) @@ -118,7 +128,13 @@ class TestCaseSqlite(unittest.TestCase): db = cr.Sqlite(path, cr.DB_PRIMARY) pkg = cr.package_from_rpm(PKG_ARCHER_PATH) db.add_pkg(pkg) + self.assertRaises(TypeError, db.add_pkg, None) + self.assertRaises(TypeError, db.add_pkg, 123) + self.assertRaises(TypeError, db.add_pkg, "foo") db.dbinfo_update("somechecksum") + self.assertRaises(TypeError, db.dbinfo_update, pkg) + self.assertRaises(TypeError, db.dbinfo_update, None) + self.assertRaises(TypeError, db.dbinfo_update, 123) db.close() self.assertTrue(os.path.isfile(path))