def test_rm_database(self): self.create_db() server = Server(**self.credentials) db = Database(self.test_db) server.rm_database(db) self.assertEqual(0, self.count_db())
def test_add_database(self): self.drop_db() server = Server(**self.credentials) db = Database(name=self.test_db, character_set="utf8") server.add_database(db) self.assertEqual(1, self.count_db()) self.drop_db()
def test_add_user(self): self.drop_user() server = Server(**self.credentials) user = User(username=self.test_user[0], password=self.test_user[1], host="localhost") result = server.add_user(user) with self.get_db() as dbms: with dbms as cursor: cursor.execute("SELECT COUNT(`User`) FROM `mysql`.`user` WHERE `User` = ?", (self.test_user[0],)) self.assertEqual(1, cursor.fetchone()[0]) self.drop_user()