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
3bb53fb4
Commit
3bb53fb4
authored
Dec 01, 2014
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for integer/float validation, fix In List filter validation
parent
5e46f3fa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
12 deletions
+84
-12
filters.py
flask_admin/contrib/mongoengine/filters.py
+4
-4
filters.py
flask_admin/contrib/peewee/filters.py
+4
-4
filters.py
flask_admin/contrib/sqla/filters.py
+4
-4
test_basic.py
flask_admin/tests/mongoengine/test_basic.py
+24
-0
test_basic.py
flask_admin/tests/peeweemodel/test_basic.py
+24
-0
test_basic.py
flask_admin/tests/sqla/test_basic.py
+24
-0
No files found.
flask_admin/contrib/mongoengine/filters.py
View file @
3bb53fb4
...
@@ -150,11 +150,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
...
@@ -150,11 +150,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
pass
pass
class
IntInListFilter
(
FilterInList
,
filters
.
BaseIntListFilter
):
class
IntInListFilter
(
filters
.
BaseIntListFilter
,
FilterInList
):
pass
pass
class
IntNotInListFilter
(
FilterNotInList
,
filters
.
BaseIntListFilter
):
class
IntNotInListFilter
(
filters
.
BaseIntListFilter
,
FilterNotInList
):
pass
pass
...
@@ -174,11 +174,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
...
@@ -174,11 +174,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
pass
pass
class
FloatInListFilter
(
FilterInList
,
filters
.
BaseFloatListFilter
):
class
FloatInListFilter
(
filters
.
BaseFloatListFilter
,
FilterInList
):
pass
pass
class
FloatNotInListFilter
(
FilterNotInList
,
filters
.
BaseFloatListFilter
):
class
FloatNotInListFilter
(
filters
.
BaseFloatListFilter
,
FilterNotInList
):
pass
pass
...
...
flask_admin/contrib/peewee/filters.py
View file @
3bb53fb4
...
@@ -139,11 +139,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
...
@@ -139,11 +139,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
pass
pass
class
IntInListFilter
(
FilterInList
,
filters
.
BaseIntListFilter
):
class
IntInListFilter
(
filters
.
BaseIntListFilter
,
FilterInList
):
pass
pass
class
IntNotInListFilter
(
FilterNotInList
,
filters
.
BaseIntListFilter
):
class
IntNotInListFilter
(
filters
.
BaseIntListFilter
,
FilterNotInList
):
pass
pass
...
@@ -163,11 +163,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
...
@@ -163,11 +163,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
pass
pass
class
FloatInListFilter
(
FilterInList
,
filters
.
BaseFloatListFilter
):
class
FloatInListFilter
(
filters
.
BaseFloatListFilter
,
FilterInList
):
pass
pass
class
FloatNotInListFilter
(
FilterNotInList
,
filters
.
BaseFloatListFilter
):
class
FloatNotInListFilter
(
filters
.
BaseFloatListFilter
,
FilterNotInList
):
pass
pass
...
...
flask_admin/contrib/sqla/filters.py
View file @
3bb53fb4
...
@@ -139,11 +139,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
...
@@ -139,11 +139,11 @@ class IntSmallerFilter(FilterSmaller, filters.BaseIntFilter):
pass
pass
class
IntInListFilter
(
FilterInList
,
filters
.
BaseIntListFilter
):
class
IntInListFilter
(
filters
.
BaseIntListFilter
,
FilterInList
):
pass
pass
class
IntNotInListFilter
(
FilterNotInList
,
filters
.
BaseIntListFilter
):
class
IntNotInListFilter
(
filters
.
BaseIntListFilter
,
FilterNotInList
):
pass
pass
...
@@ -163,11 +163,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
...
@@ -163,11 +163,11 @@ class FloatSmallerFilter(FilterSmaller, filters.BaseFloatFilter):
pass
pass
class
FloatInListFilter
(
FilterInList
,
filters
.
BaseFloatListFilter
):
class
FloatInListFilter
(
filters
.
BaseFloatListFilter
,
FilterInList
):
pass
pass
class
FloatNotInListFilter
(
FilterNotInList
,
filters
.
BaseFloatListFilter
):
class
FloatNotInListFilter
(
filters
.
BaseFloatListFilter
,
FilterNotInList
):
pass
pass
...
...
flask_admin/tests/mongoengine/test_basic.py
View file @
3bb53fb4
...
@@ -248,6 +248,12 @@ def test_column_filters():
...
@@ -248,6 +248,12 @@ def test_column_filters():
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_4'
not
in
data
)
ok_
(
'string_field_val_4'
not
in
data
)
# integer - equals - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not equal
# integer - not equal
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -296,6 +302,12 @@ def test_column_filters():
...
@@ -296,6 +302,12 @@ def test_column_filters():
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_4'
in
data
)
ok_
(
'string_field_val_4'
in
data
)
# integer - in list - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_5=5000
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not in list
# integer - not in list
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -328,6 +340,12 @@ def test_column_filters():
...
@@ -328,6 +340,12 @@ def test_column_filters():
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_4'
not
in
data
)
ok_
(
'string_field_val_4'
not
in
data
)
# float - equals - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not equal
# float - not equal
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -376,6 +394,12 @@ def test_column_filters():
...
@@ -376,6 +394,12 @@ def test_column_filters():
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_3'
in
data
)
ok_
(
'string_field_val_4'
in
data
)
ok_
(
'string_field_val_4'
in
data
)
# float - in list - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_5=25.9
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not in list
# float - not in list
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
...
flask_admin/tests/peeweemodel/test_basic.py
View file @
3bb53fb4
...
@@ -281,6 +281,12 @@ def test_column_filters():
...
@@ -281,6 +281,12 @@ def test_column_filters():
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_4'
not
in
data
)
ok_
(
'char_field_val_4'
not
in
data
)
# integer - equals - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not equal
# integer - not equal
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -329,6 +335,12 @@ def test_column_filters():
...
@@ -329,6 +335,12 @@ def test_column_filters():
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_4'
in
data
)
ok_
(
'char_field_val_4'
in
data
)
# integer - in list - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_5=5000
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not in list
# integer - not in list
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -361,6 +373,12 @@ def test_column_filters():
...
@@ -361,6 +373,12 @@ def test_column_filters():
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_4'
not
in
data
)
ok_
(
'char_field_val_4'
not
in
data
)
# float - equals - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not equal
# float - not equal
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -409,6 +427,12 @@ def test_column_filters():
...
@@ -409,6 +427,12 @@ def test_column_filters():
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_3'
in
data
)
ok_
(
'char_field_val_4'
in
data
)
ok_
(
'char_field_val_4'
in
data
)
# float - in list - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_5=25.9
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not in list
# float - not in list
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
...
flask_admin/tests/sqla/test_basic.py
View file @
3bb53fb4
...
@@ -527,6 +527,12 @@ def test_column_filters():
...
@@ -527,6 +527,12 @@ def test_column_filters():
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_4'
not
in
data
)
ok_
(
'test2_val_4'
not
in
data
)
# integer - equals - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not equal
# integer - not equal
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_1=5000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -575,6 +581,12 @@ def test_column_filters():
...
@@ -575,6 +581,12 @@ def test_column_filters():
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_4'
in
data
)
ok_
(
'test2_val_4'
in
data
)
# integer - in list - test validation
rv
=
client
.
get
(
'/admin/model2/?flt0_5=5000
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# integer - not in list
# integer - not in list
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
rv
=
client
.
get
(
'/admin/model2/?flt0_6=5000
%2
C9000'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -607,6 +619,12 @@ def test_column_filters():
...
@@ -607,6 +619,12 @@ def test_column_filters():
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_4'
not
in
data
)
ok_
(
'test2_val_4'
not
in
data
)
# float - equals - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_0=badval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not equal
# float - not equal
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_1=25.9'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -655,6 +673,12 @@ def test_column_filters():
...
@@ -655,6 +673,12 @@ def test_column_filters():
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_3'
in
data
)
ok_
(
'test2_val_4'
in
data
)
ok_
(
'test2_val_4'
in
data
)
# float - in list - test validation
rv
=
client
.
get
(
'/admin/_float/?flt0_5=25.9
%2
Cbadval'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'Invalid Filter Value'
in
data
)
# float - not in list
# float - not in list
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
rv
=
client
.
get
(
'/admin/_float/?flt0_6=25.9
%2
C75.5'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
...
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