-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMySqlDataLayerTest.py
43 lines (36 loc) · 1.36 KB
/
MySqlDataLayerTest.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from test.StratumTestCase import StratumTestCase
class MySqlDataLayerTest(StratumTestCase):
"""
Test cases for class MySqlDataLayer.
"""
# ------------------------------------------------------------------------------------------------------------------
def test_connect_if_not_alive(self):
"""
Test method connect_if_not_alive().
"""
# Reconnect when not connected.
self._dl.disconnect()
self._dl.connect_if_not_alive()
self.assertTrue(True)
# Reconnect when connected.
self._dl.connect_if_not_alive()
self.assertTrue(True)
# Reconnect when server has been gone.
try:
self._dl.execute_none('kill connection connection_id()')
except:
pass
self._dl.connect_if_not_alive()
self.assertTrue(True)
# ------------------------------------------------------------------------------------------------------------------
def test_is_alive(self):
"""
Test method is_alive().
"""
self._dl.connect()
is_alive = self._dl.is_alive()
self.assertTrue(is_alive)
self._dl.disconnect()
is_alive = self._dl.is_alive()
self.assertFalse(is_alive)
# ----------------------------------------------------------------------------------------------------------------------