File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-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+ import pytest
6+ import datajoint as dj
7+ from datajoint import DataJointError
8+ from . import CONN_INFO
9+
10+
11+ @pytest .fixture
12+ def conn (connection_root ):
13+ return dj .conn (reset = True , ** CONN_INFO )
14+
15+
16+ class TestReconnect :
17+ """
18+ Test reconnection
19+ """
20+
21+ def test_close (self , conn ):
22+ assert conn .is_connected , "Connection should be alive"
23+ conn .close ()
24+ assert not conn .is_connected , "Connection should now be closed"
25+
26+ def test_reconnect (self , conn ):
27+ assert conn .is_connected , "Connection should be alive"
28+ conn .close ()
29+ conn .query ("SHOW DATABASES;" , reconnect = True ).fetchall ()
30+ assert conn .is_connected , "Connection should be alive"
31+
32+ def test_reconnect_throws_error_in_transaction (self , conn ):
33+ assert conn .is_connected , "Connection should be alive"
34+ with conn .transaction , pytest .raises (DataJointError ):
35+ conn .close ()
36+ conn .query ("SHOW DATABASES;" , reconnect = True ).fetchall ()
You can’t perform that action at this time.
0 commit comments