File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Collection of test cases to test connection module.
3
+ """
4
+
5
+ from nose .tools import assert_true , assert_false , raises
6
+ import datajoint as dj
7
+ from datajoint import DataJointError
8
+ from . import CONN_INFO
9
+
10
+
11
+ class TestReconnect :
12
+ """
13
+ test reconnection
14
+ """
15
+
16
+ def setup (self ):
17
+ self .conn = dj .conn (reset = True , ** CONN_INFO )
18
+
19
+ def test_close (self ):
20
+ assert_true (self .conn .is_connected , "Connection should be alive" )
21
+ self .conn .close ()
22
+ assert_false (self .conn .is_connected , "Connection should now be closed" )
23
+
24
+ def test_reconnect (self ):
25
+ assert_true (self .conn .is_connected , "Connection should be alive" )
26
+ self .conn .close ()
27
+ self .conn .query ("SHOW DATABASES;" , reconnect = True ).fetchall ()
28
+ assert_true (self .conn .is_connected , "Connection should be alive" )
29
+
30
+ @raises (DataJointError )
31
+ def test_reconnect_throws_error_in_transaction (self ):
32
+ assert_true (self .conn .is_connected , "Connection should be alive" )
33
+ with self .conn .transaction :
34
+ self .conn .close ()
35
+ self .conn .query ("SHOW DATABASES;" , reconnect = True ).fetchall ()
You can’t perform that action at this time.
0 commit comments