def test_add_connection_sets_default(self): add_connection('mydb', 'sqlite:?conn=1') add_connection('mydb2', 'sqlite:?conn=2', default=True) assert getstore({}).get_database()\ is getstore({}, 'mydb2').get_database() assert getstore({}).get_database()\ is not getstore({}, 'mydb').get_database()
def test_disconnect_removes_all_connections(self): add_connection('mydb', 'sqlite:?conn=1') add_connection('mydb2', 'sqlite:?conn=2') store1 = getstore({}, 'mydb') store2 = getstore({}, 'mydb2') # Check stores are alive store1.execute("SELECT 1") store2.execute("SELECT 1") store_pool.disconnect() assert_raises(ClosedError, store1.execute, "SELECT 1") assert_raises(ClosedError, store2.execute, "SELECT 1")
def setup_class(cls): add_connection('mydb', 'sqlite:?conn=1', default=True)
def test_add_connection_creates_new_connection(self): add_connection('mydb', 'sqlite:') store = getstore({}, 'mydb') assert hasattr(store, 'execute')