forked from sqlobject/sqlobject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_postgres.py
More file actions
58 lines (40 loc) · 1.45 KB
/
Copy pathtest_postgres.py
File metadata and controls
58 lines (40 loc) · 1.45 KB
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
import os
import pytest
from sqlobject import SQLObject, StringCol
from sqlobject.tests.dbtest import getConnection, setupClass
########################################
# Test PosgreSQL sslmode
########################################
try:
connection = getConnection()
except (AttributeError, NameError):
# The module was imported during documentation building
pass
else:
if connection.dbName != "postgres":
pytestmark = pytest.mark.skip('')
class SOTestSSLMode(SQLObject):
test = StringCol()
def test_sslmode():
setupClass(SOTestSSLMode)
connection = SOTestSSLMode._connection
if (not connection.module.__name__.startswith('psycopg')) or \
(os.name == 'nt'):
pytest.skip("The test requires PostgreSQL, psycopg and ssl mode; "
"also it doesn't work on w32")
connection = getConnection(sslmode='require')
SOTestSSLMode._connection = connection
test = SOTestSSLMode(test='test') # Connect to the DB to test sslmode
connection.cache.clear()
test = SOTestSSLMode.select()[0]
assert test.test == 'test'
########################################
# Test PosgreSQL list{Database,Tables}
########################################
class SOTestSOList(SQLObject):
pass
def test_list_databases():
assert connection.db in connection.listDatabases()
def test_list_tables():
setupClass(SOTestSOList)
assert SOTestSOList.sqlmeta.table in connection.listTables()