-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtest_create_db.py
29 lines (23 loc) · 930 Bytes
/
test_create_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# encoding: utf-8
import uuid
from tornado.testing import gen_test
from . import BaseTestCase
class TestCreateDB(BaseTestCase):
@gen_test
def test1(self):
name = "test_{0}".format(uuid.uuid4().hex)
with (yield self.pool.Connection()) as connection:
yield connection.begin()
try:
with connection.cursor() as cursor:
yield cursor.execute("CREATE DATABASE {0}".format(name))
yield connection.select_db(name)
with connection.cursor() as cursor:
yield cursor.execute('SHOW TABLES')
data = cursor.fetchall()
self.assertEqual(data, tuple())
with connection.cursor() as cursor:
yield cursor.execute("DROP DATABASE {0}".format(name))
finally:
yield connection.rollback()