-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtest_sqlbuilder_importproxy.py
More file actions
55 lines (37 loc) · 1.36 KB
/
test_sqlbuilder_importproxy.py
File metadata and controls
55 lines (37 loc) · 1.36 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
from sqlobject import SQLObject, StringCol
from sqlobject.sqlbuilder import Alias, ImportProxy, tablesUsedSet
from sqlobject.views import ViewSQLObject
def testSimple():
nyi = ImportProxy('NotYetImported')
x = nyi.q.name
class NotYetImported(SQLObject):
name = StringCol(dbName='a_name')
y = nyi.q.name
assert str(x) == 'not_yet_imported.a_name'
assert str(y) == 'not_yet_imported.a_name'
def testAddition():
nyi = ImportProxy('NotYetImported2')
x = nyi.q.name + nyi.q.name
class NotYetImported2(SQLObject):
name = StringCol(dbName='a_name')
assert str(x) == \
'((not_yet_imported2.a_name) + (not_yet_imported2.a_name))'
def testOnView():
nyi = ImportProxy('NotYetImportedV')
x = nyi.q.name
class NotYetImported3(SQLObject):
name = StringCol(dbName='a_name')
class NotYetImportedV(ViewSQLObject):
class sqlmeta:
idName = NotYetImported3.q.id
name = StringCol(dbName=NotYetImported3.q.name)
assert str(x) == 'not_yet_imported_v.name'
def testAlias():
nyi = ImportProxy('NotYetImported4')
y = Alias(nyi, 'y')
x = y.q.name
class NotYetImported4(SQLObject):
name = StringCol(dbName='a_name')
assert str(y) == 'not_yet_imported4 y'
assert tablesUsedSet(x, None) == set(['not_yet_imported4 y'])
assert str(x) == 'y.a_name'