Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
78e4468f
Commit
78e4468f
authored
Jan 28, 2014
by
Ian Foote
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file upload test for APIRequestFactory
Remove test_compat
parent
74fec7ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
rest_framework/tests/test_compat.py
+0
-13
rest_framework/tests/test_testing.py
+9
-0
No files found.
rest_framework/tests/test_compat.py
deleted
100644 → 0
View file @
74fec7ee
import
django
from
django.test
import
TestCase
class
TestCompat
(
TestCase
):
def
test_force_bytes_or_smart_bytes
(
self
):
from
rest_framework.compat
import
force_bytes_or_smart_bytes
if
django
.
VERSION
>=
(
1
,
5
):
from
django.utils.encoding
import
force_bytes
self
.
assertEqual
(
force_bytes_or_smart_bytes
,
force_bytes
)
else
:
from
django.utils.encoding
import
smart_str
self
.
assertEqual
(
force_bytes_or_smart_bytes
,
smart_str
)
rest_framework/tests/test_testing.py
View file @
78e4468f
# -- coding: utf-8 --
# -- coding: utf-8 --
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
io
import
BytesIO
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
from
django.test
import
TestCase
from
rest_framework.compat
import
patterns
,
url
from
rest_framework.compat
import
patterns
,
url
...
@@ -143,3 +145,10 @@ class TestAPIRequestFactory(TestCase):
...
@@ -143,3 +145,10 @@ class TestAPIRequestFactory(TestCase):
force_authenticate
(
request
,
user
=
user
)
force_authenticate
(
request
,
user
=
user
)
response
=
view
(
request
)
response
=
view
(
request
)
self
.
assertEqual
(
response
.
data
[
'user'
],
'example'
)
self
.
assertEqual
(
response
.
data
[
'user'
],
'example'
)
def
test_upload_file
(
self
):
# This is a 1x1 black png
simple_png
=
BytesIO
(
b
'
\x89
PNG
\r\n\x1a\n\x00\x00\x00\r
IHDR
\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\r
IDATx
\x9c
c````
\x00\x00\x00\x05\x00\x01\xa5\xf6
E@
\x00\x00\x00\x00
IEND
\xae
B`
\x82
'
)
simple_png
.
name
=
'test.png'
factory
=
APIRequestFactory
()
factory
.
post
(
'/'
,
data
=
{
'image'
:
simple_png
})
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