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
955271ef
Commit
955271ef
authored
Jul 01, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for edit_modal
parent
8bdccd0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
test_model.py
flask_admin/tests/test_model.py
+47
-0
No files found.
flask_admin/tests/test_model.py
View file @
955271ef
...
...
@@ -452,6 +452,53 @@ def test_custom_form():
ok_
(
not
hasattr
(
view
.
_create_form_class
,
'col1'
))
def
test_modal_edit
():
# bootstrap 2 - test edit_modal
app_bs2
=
Flask
(
__name__
)
admin_bs2
=
Admin
(
app_bs2
,
template_mode
=
"bootstrap2"
)
modal_view
=
MockModelView
(
Model
,
edit_modal
=
True
,
endpoint
=
"modal_on"
)
no_modal_view
=
MockModelView
(
Model
,
edit_modal
=
False
,
endpoint
=
"modal_off"
)
admin_bs2
.
add_view
(
modal_view
)
admin_bs2
.
add_view
(
no_modal_view
)
client_bs2
=
app_bs2
.
test_client
()
# bootstrap 2 - ensure modal window is added when edit_modal is enabled
rv
=
client_bs2
.
get
(
'/admin/modal_on/'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'fa_modal_window'
in
data
)
# bootstrap 2 - test modal disabled
rv
=
client_bs2
.
get
(
'/admin/modal_off/'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'fa_modal_window'
not
in
data
)
# bootstrap 3
app_bs3
=
Flask
(
__name__
)
admin_bs3
=
Admin
(
app_bs3
,
template_mode
=
"bootstrap3"
)
admin_bs3
.
add_view
(
modal_view
)
admin_bs3
.
add_view
(
no_modal_view
)
client_bs3
=
app_bs3
.
test_client
()
# bootstrap 3 - ensure modal window is added when edit_modal is enabled
rv
=
client_bs3
.
get
(
'/admin/modal_on/'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'fa_modal_window'
in
data
)
# bootstrap 3 - test modal disabled
rv
=
client_bs3
.
get
(
'/admin/modal_off/'
)
eq_
(
rv
.
status_code
,
200
)
data
=
rv
.
data
.
decode
(
'utf-8'
)
ok_
(
'fa_modal_window'
not
in
data
)
def
check_class_name
():
class
DummyView
(
MockModelView
):
pass
...
...
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