Skip to content

Commit fdaa06d

Browse files
Start implementing test
1 parent b8609af commit fdaa06d

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

pymysqlreplication/tests/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pymysqlreplication.tests.test_basic import *
2+
3+
if __name__ == "__main__":
4+
import unittest
5+
unittest.main()
6+

pymysqlreplication/tests/base.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pymysql
2+
import unittest
3+
4+
class PyMySQLReplicationTestCase(unittest.TestCase):
5+
'''Test the module. Be carefull it will reset your MySQL server'''
6+
database = {"host":"localhost","user":"root", "passwd":"","use_unicode": True}
7+
8+
def setUp(self):
9+
self.conn_control = pymysql.connect(**self.database)
10+
self.conn_test = pymysql.connect(**self.database)
11+
self.execute("CREATE DATABASE pymysqlreplication_test")
12+
self.resetBinLog()
13+
14+
def tearDown(self):
15+
self.execute("DROP DATABASE pymysqlreplication_test")
16+
self.conn_control.close()
17+
self.conn_test.close()
18+
19+
def execute(self, query):
20+
c = self.conn_control.cursor()
21+
c.execute(query)
22+
23+
def resetBinLog(self):
24+
self.execute("RESET MASTER")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import base
2+
from pymysqlreplication import BinLogStreamReader
3+
4+
class TestBinLogStreamReader(base.PyMySQLReplicationTestCase):
5+
def test_open_stream(self):
6+
""" test opening stream"""
7+
stream = BinLogStreamReader(self.conn_test)
8+
9+
10+
__all__ = ["TestBinLogStreamReader"]
11+
12+
if __name__ == "__main__":
13+
import unittest
14+
unittest.main()

0 commit comments

Comments
 (0)