File size: 2,444 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import time

import redshift_connector

driver = redshift_connector


def test_apilevel() -> None:
    # Must exist
    apilevel: str = driver.apilevel

    # Must equal 2.0
    assert apilevel == "2.0"


def test_threadsafety() -> None:
    try:
        # Must exist
        threadsafety: int = driver.threadsafety
        # Must be a valid value
        assert threadsafety in (0, 1, 2, 3)
    except AttributeError:
        assert False, "Driver doesn't define threadsafety"


def test_paramstyle() -> None:
    from redshift_connector.config import DbApiParamstyle

    try:
        # Must exist
        paramstyle: str = driver.paramstyle
        # Must be a valid value
        assert paramstyle in DbApiParamstyle.list()
    except AttributeError:
        assert False, "Driver doesn't define paramstyle"


def test_Exceptions() -> None:
    # Make sure required exceptions exist, and are in the
    # defined heirarchy.
    assert issubclass(driver.Warning, Exception)
    assert issubclass(driver.Error, Exception)
    assert issubclass(driver.InterfaceError, driver.Error)
    assert issubclass(driver.DatabaseError, driver.Error)
    assert issubclass(driver.OperationalError, driver.Error)
    assert issubclass(driver.IntegrityError, driver.Error)
    assert issubclass(driver.InternalError, driver.Error)
    assert issubclass(driver.ProgrammingError, driver.Error)
    assert issubclass(driver.NotSupportedError, driver.Error)


def test_Date() -> None:
    driver.Date(2002, 12, 25)
    driver.DateFromTicks(time.mktime((2002, 12, 25, 0, 0, 0, 0, 0, 0)))


def test_Time() -> None:
    driver.Time(13, 45, 30)
    driver.TimeFromTicks(time.mktime((2001, 1, 1, 13, 45, 30, 0, 0, 0)))


def test_Timestamp() -> None:
    driver.Timestamp(2002, 12, 25, 13, 45, 30)
    driver.TimestampFromTicks(time.mktime((2002, 12, 25, 13, 45, 30, 0, 0, 0)))


def test_Binary() -> None:
    driver.Binary(b"Something")
    driver.Binary(b"")


def test_STRING() -> None:
    assert hasattr(driver, "STRING"), "module.STRING must be defined"


def test_BINARY() -> None:
    assert hasattr(driver, "BINARY"), "module.BINARY must be defined."


def test_NUMBER() -> None:
    assert hasattr(driver, "NUMBER"), "module.NUMBER must be defined."


def test_DATETIME() -> None:
    assert hasattr(driver, "DATETIME"), "module.DATETIME must be defined."


def test_ROWID() -> None:
    assert hasattr(driver, "ROWID"), "module.ROWID must be defined."