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
315e8d28
Commit
315e8d28
authored
Apr 18, 2016
by
Sebastien Flory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for SortedListField in mongoengine
parent
15a3d1df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
test_basic.py
flask_admin/tests/mongoengine/test_basic.py
+57
-0
No files found.
flask_admin/tests/mongoengine/test_basic.py
View file @
315e8d28
...
@@ -908,6 +908,63 @@ def test_nested_list_subdocument():
...
@@ -908,6 +908,63 @@ def test_nested_list_subdocument():
ok_
(
'value'
not
in
dir
(
inline_form
))
ok_
(
'value'
not
in
dir
(
inline_form
))
def
test_nested_sortedlist_subdocument
():
app
,
db
,
admin
=
setup
()
class
Comment
(
db
.
EmbeddedDocument
):
name
=
db
.
StringField
(
max_length
=
20
,
required
=
True
)
value
=
db
.
StringField
(
max_length
=
20
)
class
Model1
(
db
.
Document
):
test1
=
db
.
StringField
(
max_length
=
20
)
subdoc
=
db
.
SortedListField
(
db
.
EmbeddedDocumentField
(
Comment
))
# Check only
view1
=
CustomModelView
(
Model1
,
form_subdocuments
=
{
'subdoc'
:
{
'form_subdocuments'
:
{
None
:
{
'form_columns'
:
(
'name'
,)
}
}
}
}
)
form
=
view1
.
create_form
()
inline_form
=
form
.
subdoc
.
unbound_field
.
args
[
2
]
ok_
(
'name'
in
dir
(
inline_form
))
ok_
(
'value'
not
in
dir
(
inline_form
))
def
test_sortedlist_subdocument_validation
():
app
,
db
,
admin
=
setup
()
class
Comment
(
db
.
EmbeddedDocument
):
name
=
db
.
StringField
(
max_length
=
20
,
required
=
True
)
value
=
db
.
StringField
(
max_length
=
20
)
class
Model1
(
db
.
Document
):
test1
=
db
.
StringField
(
max_length
=
20
)
subdoc
=
db
.
SortedListField
(
db
.
EmbeddedDocumentField
(
Comment
))
view
=
CustomModelView
(
Model1
)
admin
.
add_view
(
view
)
client
=
app
.
test_client
()
rv
=
client
.
post
(
'/admin/model1/new/'
,
data
=
{
'test1'
:
'test1large'
,
'subdoc-0-name'
:
'comment'
,
'subdoc-0-value'
:
'test'
})
eq_
(
rv
.
status_code
,
302
)
rv
=
client
.
post
(
'/admin/model1/new/'
,
data
=
{
'test1'
:
'test1large'
,
'subdoc-0-name'
:
''
,
'subdoc-0-value'
:
'test'
})
eq_
(
rv
.
status_code
,
200
)
ok_
(
'This field is required'
in
rv
.
data
)
def
test_list_subdocument_validation
():
def
test_list_subdocument_validation
():
app
,
db
,
admin
=
setup
()
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