Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
45427538
Commit
45427538
authored
Dec 09, 2016
by
Skia
🤘
Browse files
Add two tests for file upload
parent
a02d5a65
Pipeline
#484
passed with stage
in 2 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
core/tests.py
View file @
45427538
...
...
@@ -269,3 +269,30 @@ http://git.an
# - renaming a page
# - changing a page's parent --> check that page's children's full_name
# - changing the different groups of the page
class
FileHandlingTest
(
TestCase
):
def
setUp
(
self
):
try
:
call_command
(
"populate"
)
self
.
subscriber
=
User
.
objects
.
filter
(
username
=
"subscriber"
).
first
()
self
.
client
.
login
(
username
=
'subscriber'
,
password
=
'plop'
)
except
Exception
as
e
:
print
(
e
)
def
test_create_folder_home
(
self
):
response
=
self
.
client
.
post
(
reverse
(
"core:file_detail"
,
kwargs
=
{
"file_id"
:
self
.
subscriber
.
home
.
id
}),
{
"folder_name"
:
"GUY_folder_test"
})
self
.
assertTrue
(
response
.
status_code
==
302
)
response
=
self
.
client
.
get
(
reverse
(
"core:file_detail"
,
kwargs
=
{
"file_id"
:
self
.
subscriber
.
home
.
id
}))
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
"GUY_folder_test</a>"
in
str
(
response
.
content
))
def
test_upload_file_home
(
self
):
with
open
(
"/bin/ls"
,
"rb"
)
as
f
:
response
=
self
.
client
.
post
(
reverse
(
"core:file_detail"
,
kwargs
=
{
"file_id"
:
self
.
subscriber
.
home
.
id
}),
{
"file_field"
:
f
})
self
.
assertTrue
(
response
.
status_code
==
302
)
response
=
self
.
client
.
get
(
reverse
(
"core:file_detail"
,
kwargs
=
{
"file_id"
:
self
.
subscriber
.
home
.
id
}))
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
"ls</a>"
in
str
(
response
.
content
))
core/views/files.py
View file @
45427538
...
...
@@ -194,7 +194,7 @@ class FileModerationView(TemplateView):
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
FileModerationView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'files'
]
=
SithFile
.
objects
.
filter
(
is_moderated
=
False
)
.
all
()
kwargs
[
'files'
]
=
SithFile
.
objects
.
filter
(
is_moderated
=
False
)
[:
100
]
return
kwargs
class
FileModerateView
(
CanEditPropMixin
,
SingleObjectMixin
):
...
...
Write
Preview
Supports
Markdown
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