FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlobject/sqlobject/tests/test_default_style.py at master · sqlobject/sqlobject · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlobject
/
sqlobject
Public
Notifications
You must be signed in to change notification settings
Fork
26
Star
156
Code
Issues
2
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_default_style.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (52 loc) · 1.95 KB
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_default_style.py
Copy path
File metadata and controls
65 lines (52 loc) · 1.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""
Test the default styles, to guarantee consistency.
"""
from
sqlobject
import
ForeignKey
,
MixedCaseStyle
,
MixedCaseUnderscoreStyle
, \
SQLObject
,
StringCol
,
Style
# Hash of styles versus the database names resulting from 'columns' below.
columns
=
[
"ABCUpper"
,
"abc_lower"
,
"ABCamelCaseColumn"
]
styles
=
{
Style
:
columns
,
MixedCaseUnderscoreStyle
: [
"abc_upper"
,
"abc_lower"
,
"ab_camel_case_column"
],
MixedCaseStyle
: [
"ABCUpper"
,
"Abc_lower"
,
"ABCamelCaseColumn"
],
}
# Hash of styles versus the database names
# resulting from a foreign key named 'FKey'.
fkey
=
ForeignKey
(
"DefaultStyleTest"
,
name
=
"FKey"
)
fkeys
=
{
Style
:
"FKeyID"
,
MixedCaseUnderscoreStyle
:
"f_key_id"
,
MixedCaseStyle
:
"FKeyID"
,
}
def
make_columns
():
global
columns
columns
=
[]
for
col_name
in
columns
:
columns
.
append
(
StringCol
(
name
=
col_name
,
length
=
10
))
def
do_col_test
(
DefaultStyleTest
,
style
,
dbnames
):
DefaultStyleTest
.
sqlmeta
.
style
=
style
()
for
col
,
old_dbname
in
zip
(
columns
,
dbnames
):
DefaultStyleTest
.
sqlmeta
.
addColumn
(
col
)
try
:
new_dbname
=
DefaultStyleTest
.
sqlmeta
.
columns
[
col
.
name
].
dbName
assert
new_dbname
==
old_dbname
finally
:
if
col
.
name
in
DefaultStyleTest
.
sqlmeta
.
columns
:
DefaultStyleTest
.
sqlmeta
.
delColumn
(
col
)
def
do_fkey_test
(
DefaultStyleTest
,
style
,
dbname
):
DefaultStyleTest
.
sqlmeta
.
style
=
style
()
DefaultStyleTest
.
sqlmeta
.
addColumn
(
fkey
)
try
:
assert
list
(
DefaultStyleTest
.
sqlmeta
.
columns
.
keys
())[
0
]
==
"FKeyID"
assert
list
(
DefaultStyleTest
.
sqlmeta
.
columns
.
values
())[
0
].
dbName
==
\
dbname
finally
:
DefaultStyleTest
.
sqlmeta
.
delColumn
(
fkey
)
class
DefaultStyleTest
(
SQLObject
):
pass
def
test_default_styles
():
make_columns
()
for
style
in
styles
:
do_col_test
(
DefaultStyleTest
,
style
,
styles
[
style
])
do_fkey_test
(
DefaultStyleTest
,
style
,
fkeys
[
style
])
Back
|
FazBrowse Home
|
New Git URL