Skip to content

Commit

Permalink
Merge pull request #1133 from ethho/dev-tests-plat-161-reconn
Browse files Browse the repository at this point in the history
PLAT-161: Migrate test_reconnection
  • Loading branch information
A-Baji authored Dec 13, 2023
2 parents 88ca9b6 + e128632 commit 46a015c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_reconnection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Collection of test cases to test connection module.
"""

import pytest
import datajoint as dj
from datajoint import DataJointError
from . import CONN_INFO


@pytest.fixture
def conn(connection_root):
return dj.conn(reset=True, **CONN_INFO)


class TestReconnect:
"""
Test reconnection
"""

def test_close(self, conn):
assert conn.is_connected, "Connection should be alive"
conn.close()
assert not conn.is_connected, "Connection should now be closed"

def test_reconnect(self, conn):
assert conn.is_connected, "Connection should be alive"
conn.close()
conn.query("SHOW DATABASES;", reconnect=True).fetchall()
assert conn.is_connected, "Connection should be alive"

def test_reconnect_throws_error_in_transaction(self, conn):
assert conn.is_connected, "Connection should be alive"
with conn.transaction, pytest.raises(DataJointError):
conn.close()
conn.query("SHOW DATABASES;", reconnect=True).fetchall()

0 comments on commit 46a015c

Please sign in to comment.