-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix failover partner connection rotation Should address issue: #167
- Loading branch information
1 parent
cc94dcb
commit c186dec
Showing
3 changed files
with
54 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
import pytds | ||
import unittest | ||
import settings | ||
from pytds import ( | ||
connect, | ||
Error | ||
) | ||
|
||
LIVE_TEST = getattr(settings, "LIVE_TEST", True) | ||
|
||
|
||
|
||
@unittest.skipUnless(LIVE_TEST, "requires HOST variable to be set") | ||
def test_connection_no_mars_no_pooling(): | ||
kwargs = settings.CONNECT_KWARGS.copy() | ||
kwargs.update( | ||
{ | ||
"use_mars": False, | ||
"pooling": False, | ||
} | ||
) | ||
with connect(**kwargs) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute("select 1") | ||
assert cur.fetchall() == [(1,)] | ||
|
||
|
||
@unittest.skipUnless(LIVE_TEST, "requires HOST variable to be set") | ||
def test_failover_partner(): | ||
kwargs = settings.CONNECT_KWARGS.copy() | ||
kwargs.update( | ||
{ | ||
"server": "192.168.1.1\\sqlexpress-doesnotexist", | ||
"failover_partner": settings.CONNECT_KWARGS["server"], | ||
"pooling": False, | ||
} | ||
) | ||
with connect(**kwargs) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute("select 1") | ||
assert cur.fetchall() == [(1,)] |