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
32f9bd9f
Commit
32f9bd9f
authored
Oct 23, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fileadmin test.
parent
1f333b3e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
test_fileadmin.py
flask_admin/tests/fileadmin/test_fileadmin.py
+29
-21
No files found.
flask_admin/tests/fileadmin/test_fileadmin.py
View file @
32f9bd9f
...
@@ -2,7 +2,7 @@ import os
...
@@ -2,7 +2,7 @@ import os
import
os.path
as
op
import
os.path
as
op
import
unittest
import
unittest
from
nose.tools
import
eq_
,
ok_
,
with_setup
from
nose.tools
import
eq_
,
ok_
from
flask_admin.contrib
import
fileadmin
from
flask_admin.contrib
import
fileadmin
from
flask_admin
import
Admin
from
flask_admin
import
Admin
...
@@ -138,21 +138,24 @@ class Base:
...
@@ -138,21 +138,24 @@ class Base:
ok_
(
'path=dummy_renamed_dir'
not
in
rv
.
data
.
decode
(
'utf-8'
))
ok_
(
'path=dummy_renamed_dir'
not
in
rv
.
data
.
decode
(
'utf-8'
))
ok_
(
'path=dummy.txt'
in
rv
.
data
.
decode
(
'utf-8'
))
ok_
(
'path=dummy.txt'
in
rv
.
data
.
decode
(
'utf-8'
))
def
add_file
(
):
def
test_fileadmin_sort_bogus_url_param
(
self
):
# make sure that 'files/dummy2.txt' exists, is newest and has bigger size
fileadmin_class
=
self
.
fileadmin_class
()
with
open
(
op
.
join
(
op
.
dirname
(
__file__
),
'files'
,
'dummy2.txt'
),
'w'
)
as
fp
:
fileadmin_args
,
fileadmin_kwargs
=
self
.
fileadmin_args
()
fp
.
write
(
'test'
)
app
,
admin
=
setup
(
)
def
remove_file
():
class
MyFileAdmin
(
fileadmin_class
):
try
:
editable_extensions
=
(
'txt'
,)
os
.
remove
(
op
.
join
(
op
.
dirname
(
__file__
),
'files'
,
'dummy2.txt'
))
except
(
IOError
,
OSError
):
view_kwargs
=
dict
(
fileadmin_kwargs
)
pass
view_kwargs
.
setdefault
(
'name'
,
'Files'
)
view
=
MyFileAdmin
(
*
fileadmin_args
,
**
view_kwargs
)
admin
.
add_view
(
view
)
@
with_setup
(
add_file
,
remove_file
)
def
test_fileadmin_sort_bogus_url_param
():
app
,
admin
,
view
=
create_view
()
client
=
app
.
test_client
()
client
=
app
.
test_client
()
with
open
(
op
.
join
(
self
.
_test_files_root
,
'dummy2.txt'
),
'w'
)
as
fp
:
# make sure that 'files/dummy2.txt' exists, is newest and has bigger size
fp
.
write
(
'test'
)
rv
=
client
.
get
(
'/admin/myfileadmin/?sort=bogus'
)
rv
=
client
.
get
(
'/admin/myfileadmin/?sort=bogus'
)
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
...
@@ -163,6 +166,11 @@ class Base:
...
@@ -163,6 +166,11 @@ class Base:
eq_
(
rv
.
status_code
,
200
)
eq_
(
rv
.
status_code
,
200
)
ok_
(
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy.txt'
)
<
ok_
(
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy.txt'
)
<
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy2.txt'
))
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy2.txt'
))
try
:
# clean up
os
.
remove
(
op
.
join
(
self
.
_test_files_root
,
'dummy2.txt'
))
except
(
IOError
,
OSError
):
pass
def
test_modal_edit
(
self
):
def
test_modal_edit
(
self
):
# bootstrap 2 - test edit_modal
# bootstrap 2 - test edit_modal
...
...
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