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
358445c1
Commit
358445c1
authored
Sep 24, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop redundant OPTIONS tests
parent
630d4720
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
180 deletions
+0
-180
tests/test_generics.py
+0
-180
No files found.
tests/test_generics.py
View file @
358445c1
...
@@ -23,25 +23,16 @@ class ForeignKeySerializer(serializers.ModelSerializer):
...
@@ -23,25 +23,16 @@ class ForeignKeySerializer(serializers.ModelSerializer):
class
RootView
(
generics
.
ListCreateAPIView
):
class
RootView
(
generics
.
ListCreateAPIView
):
"""
Example description for OPTIONS.
"""
queryset
=
BasicModel
.
objects
.
all
()
queryset
=
BasicModel
.
objects
.
all
()
serializer_class
=
BasicSerializer
serializer_class
=
BasicSerializer
class
InstanceView
(
generics
.
RetrieveUpdateDestroyAPIView
):
class
InstanceView
(
generics
.
RetrieveUpdateDestroyAPIView
):
"""
Example description for OPTIONS.
"""
queryset
=
BasicModel
.
objects
.
exclude
(
text
=
'filtered out'
)
queryset
=
BasicModel
.
objects
.
exclude
(
text
=
'filtered out'
)
serializer_class
=
BasicSerializer
serializer_class
=
BasicSerializer
class
FKInstanceView
(
generics
.
RetrieveUpdateDestroyAPIView
):
class
FKInstanceView
(
generics
.
RetrieveUpdateDestroyAPIView
):
"""
FK: example description for OPTIONS.
"""
queryset
=
ForeignKeySource
.
objects
.
all
()
queryset
=
ForeignKeySource
.
objects
.
all
()
serializer_class
=
ForeignKeySerializer
serializer_class
=
ForeignKeySerializer
...
@@ -122,47 +113,6 @@ class TestRootView(TestCase):
...
@@ -122,47 +113,6 @@ class TestRootView(TestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_405_METHOD_NOT_ALLOWED
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_405_METHOD_NOT_ALLOWED
)
self
.
assertEqual
(
response
.
data
,
{
"detail"
:
"Method 'DELETE' not allowed."
})
self
.
assertEqual
(
response
.
data
,
{
"detail"
:
"Method 'DELETE' not allowed."
})
# def test_options_root_view(self):
# """
# OPTIONS requests to ListCreateAPIView should return metadata
# """
# request = factory.options('/')
# with self.assertNumQueries(0):
# response = self.view(request).render()
# expected = {
# 'parses': [
# 'application/json',
# 'application/x-www-form-urlencoded',
# 'multipart/form-data'
# ],
# 'renders': [
# 'application/json',
# 'text/html'
# ],
# 'name': 'Root',
# 'description': 'Example description for OPTIONS.',
# 'actions': {
# 'POST': {
# 'text': {
# 'max_length': 100,
# 'read_only': False,
# 'required': True,
# 'type': 'string',
# "label": "Text comes here",
# "help_text": "Text description."
# },
# 'id': {
# 'read_only': True,
# 'required': False,
# 'type': 'integer',
# 'label': 'ID',
# },
# }
# }
# }
# self.assertEqual(response.status_code, status.HTTP_200_OK)
# self.assertEqual(response.data, expected)
def
test_post_cannot_set_id
(
self
):
def
test_post_cannot_set_id
(
self
):
"""
"""
POST requests to create a new object should not be able to set the id.
POST requests to create a new object should not be able to set the id.
...
@@ -256,89 +206,6 @@ class TestInstanceView(TestCase):
...
@@ -256,89 +206,6 @@ class TestInstanceView(TestCase):
ids
=
[
obj
.
id
for
obj
in
self
.
objects
.
all
()]
ids
=
[
obj
.
id
for
obj
in
self
.
objects
.
all
()]
self
.
assertEqual
(
ids
,
[
2
,
3
])
self
.
assertEqual
(
ids
,
[
2
,
3
])
# def test_options_instance_view(self):
# """
# OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata
# """
# request = factory.options('/1')
# with self.assertNumQueries(1):
# response = self.view(request, pk=1).render()
# expected = {
# 'parses': [
# 'application/json',
# 'application/x-www-form-urlencoded',
# 'multipart/form-data'
# ],
# 'renders': [
# 'application/json',
# 'text/html'
# ],
# 'name': 'Instance',
# 'description': 'Example description for OPTIONS.',
# 'actions': {
# 'PUT': {
# 'text': {
# 'max_length': 100,
# 'read_only': False,
# 'required': True,
# 'type': 'string',
# 'label': 'Text comes here',
# 'help_text': 'Text description.'
# },
# 'id': {
# 'read_only': True,
# 'required': False,
# 'type': 'integer',
# 'label': 'ID',
# },
# }
# }
# }
# self.assertEqual(response.status_code, status.HTTP_200_OK)
# self.assertEqual(response.data, expected)
# def test_options_before_instance_create(self):
# """
# OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata
# before the instance has been created
# """
# request = factory.options('/999')
# with self.assertNumQueries(1):
# response = self.view(request, pk=999).render()
# expected = {
# 'parses': [
# 'application/json',
# 'application/x-www-form-urlencoded',
# 'multipart/form-data'
# ],
# 'renders': [
# 'application/json',
# 'text/html'
# ],
# 'name': 'Instance',
# 'description': 'Example description for OPTIONS.',
# 'actions': {
# 'PUT': {
# 'text': {
# 'max_length': 100,
# 'read_only': False,
# 'required': True,
# 'type': 'string',
# 'label': 'Text comes here',
# 'help_text': 'Text description.'
# },
# 'id': {
# 'read_only': True,
# 'required': False,
# 'type': 'integer',
# 'label': 'ID',
# },
# }
# }
# }
# self.assertEqual(response.status_code, status.HTTP_200_OK)
# self.assertEqual(response.data, expected)
def
test_get_instance_view_incorrect_arg
(
self
):
def
test_get_instance_view_incorrect_arg
(
self
):
"""
"""
GET requests with an incorrect pk type, should raise 404, not 500.
GET requests with an incorrect pk type, should raise 404, not 500.
...
@@ -415,53 +282,6 @@ class TestFKInstanceView(TestCase):
...
@@ -415,53 +282,6 @@ class TestFKInstanceView(TestCase):
]
]
self
.
view
=
FKInstanceView
.
as_view
()
self
.
view
=
FKInstanceView
.
as_view
()
# def test_options_root_view(self):
# """
# OPTIONS requests to ListCreateAPIView should return metadata
# """
# request = factory.options('/999')
# with self.assertNumQueries(1):
# response = self.view(request, pk=999).render()
# expected = {
# 'name': 'Fk Instance',
# 'description': 'FK: example description for OPTIONS.',
# 'renders': [
# 'application/json',
# 'text/html'
# ],
# 'parses': [
# 'application/json',
# 'application/x-www-form-urlencoded',
# 'multipart/form-data'
# ],
# 'actions': {
# 'PUT': {
# 'id': {
# 'type': 'integer',
# 'required': False,
# 'read_only': True,
# 'label': 'ID'
# },
# 'name': {
# 'type': 'string',
# 'required': True,
# 'read_only': False,
# 'label': 'name',
# 'max_length': 100
# },
# 'target': {
# 'type': 'field',
# 'required': True,
# 'read_only': False,
# 'label': 'Target',
# 'help_text': 'Target'
# }
# }
# }
# }
# self.assertEqual(response.status_code, status.HTTP_200_OK)
# self.assertEqual(response.data, expected)
class
TestOverriddenGetObject
(
TestCase
):
class
TestOverriddenGetObject
(
TestCase
):
"""
"""
...
...
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