File: connection_test.py

package info (click to toggle)
pytds 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 868 kB
  • sloc: python: 12,831; makefile: 199; sh: 8
file content (42 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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,)]