Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
1bbe9c3a
Commit
1bbe9c3a
authored
Dec 08, 2014
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #729 from pawl/fixcolumnlabel
Add test for single custom filter on relation and column_labels
parents
58789da1
377b7d33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
+26
-4
test_basic.py
flask_admin/tests/sqla/test_basic.py
+26
-4
No files found.
flask_admin/tests/sqla/test_basic.py
View file @
1bbe9c3a
...
...
@@ -5,7 +5,7 @@ from wtforms import fields
from
flask.ext.admin
import
form
from
flask.ext.admin._compat
import
as_unicode
from
flask.ext.admin._compat
import
iteritems
from
flask.ext.admin.contrib.sqla
import
ModelView
from
flask.ext.admin.contrib.sqla
import
ModelView
,
filters
from
flask.ext.babelex
import
Babel
from
.
import
setup
...
...
@@ -377,7 +377,17 @@ def test_column_filters():
(
0
,
'equals'
),
(
1
,
'not equal'
),
])
# Test column_labels on filters
view
=
CustomModelView
(
Model2
,
db
.
session
,
column_filters
=
[
'model1.bool_field'
,
'string_field'
],
column_labels
=
{
'model1.bool_field'
:
'Test Filter #1'
,
'string_field'
:
'Test Filter #2'
,
})
eq_
(
view
.
_filter_groups
.
keys
(),
[
u'Test Filter #1'
,
u'Test Filter #2'
])
# Fill DB
model1_obj1
=
Model1
(
'test1_val_1'
,
'test2_val_1'
,
bool_field
=
True
)
model1_obj2
=
Model1
(
'test1_val_2'
,
'test2_val_2'
)
...
...
@@ -385,7 +395,7 @@ def test_column_filters():
model1_obj4
=
Model1
(
'test1_val_4'
,
'test2_val_4'
)
model2_obj1
=
Model2
(
'test2_val_1'
,
model1
=
model1_obj1
,
float_field
=
None
)
model2_obj2
=
Model2
(
'test2_val_2'
,
model1
=
model1_obj
1
,
float_field
=
None
)
model2_obj2
=
Model2
(
'test2_val_2'
,
model1
=
model1_obj
2
,
float_field
=
None
)
model2_obj3
=
Model2
(
'test2_val_3'
,
int_field
=
5000
,
float_field
=
25.9
)
model2_obj4
=
Model2
(
'test2_val_4'
,
int_field
=
9000
,
float_field
=
75.5
)
...
...
@@ -705,7 +715,7 @@ def test_column_filters():
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'test2_val_1'
in
data
)
ok_
(
'test2_val_2'
in
data
)
ok_
(
'test2_val_2'
not
in
data
)
ok_
(
'test2_val_3'
not
in
data
)
ok_
(
'test2_val_4'
not
in
data
)
...
...
@@ -989,6 +999,18 @@ def test_column_filters():
ok_
(
'enum_obj1'
not
in
data
)
ok_
(
'enum_obj2'
not
in
data
)
# Test single custom filter on relation
view
=
CustomModelView
(
Model2
,
db
.
session
,
column_filters
=
[
filters
.
FilterEqual
(
Model1
.
test1
,
"Test1"
)
],
endpoint
=
'_relation_test'
)
admin
.
add_view
(
view
)
rv
=
client
.
get
(
'/admin/_relation_test/?flt1_0=test1_val_1'
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'test1_val_1'
in
data
)
ok_
(
'test1_val_2'
not
in
data
)
def
test_url_args
():
app
,
db
,
admin
=
setup
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment