mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Modify test code
This commit is contained in:
parent
9b88ea7da7
commit
eb80328356
|
@ -109,12 +109,6 @@ class TestRouterGeneratedSchema(TestCase):
|
|||
url='/example/custom_list_action/',
|
||||
action='get'
|
||||
),
|
||||
'custom_list_action_multiple_methods': {
|
||||
'read': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='get'
|
||||
)
|
||||
},
|
||||
'read': coreapi.Link(
|
||||
url='/example/{id}/',
|
||||
action='get',
|
||||
|
@ -122,6 +116,12 @@ class TestRouterGeneratedSchema(TestCase):
|
|||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
)
|
||||
},
|
||||
'example-custom_list_action_multiple_methods': {
|
||||
'read': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='get'
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -162,31 +162,6 @@ class TestRouterGeneratedSchema(TestCase):
|
|||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
),
|
||||
'custom_action': coreapi.Link(
|
||||
url='/example/{id}/custom_action/',
|
||||
action='post',
|
||||
encoding='application/json',
|
||||
description='A description of custom action.',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String()),
|
||||
coreapi.Field('c', required=True, location='form', schema=coreschema.String(title='C')),
|
||||
coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')),
|
||||
]
|
||||
),
|
||||
'custom_list_action': coreapi.Link(
|
||||
url='/example/custom_list_action/',
|
||||
action='get'
|
||||
),
|
||||
'custom_list_action_multiple_methods': {
|
||||
'read': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='get'
|
||||
),
|
||||
'create': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='post'
|
||||
)
|
||||
},
|
||||
'update': coreapi.Link(
|
||||
url='/example/{id}/',
|
||||
action='put',
|
||||
|
@ -213,8 +188,33 @@ class TestRouterGeneratedSchema(TestCase):
|
|||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
),
|
||||
'custom_list_action': coreapi.Link(
|
||||
url='/example/custom_list_action/',
|
||||
action='get'
|
||||
),
|
||||
'custom_action': coreapi.Link(
|
||||
url='/example/{id}/custom_action/',
|
||||
action='post',
|
||||
encoding='application/json',
|
||||
description='A description of custom action.',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String()),
|
||||
coreapi.Field('c', required=True, location='form', schema=coreschema.String(title='C')),
|
||||
coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')),
|
||||
]
|
||||
)
|
||||
}
|
||||
},
|
||||
'example-custom_list_action_multiple_methods': {
|
||||
'read': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='get'
|
||||
),
|
||||
'create': coreapi.Link(
|
||||
url='/example/custom_list_action_multiple_methods/',
|
||||
action='post'
|
||||
)
|
||||
},
|
||||
}
|
||||
)
|
||||
assert response.data == expected
|
||||
|
@ -299,16 +299,15 @@ class TestSchemaGenerator(TestCase):
|
|||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
),
|
||||
'sub': {
|
||||
'list': coreapi.Link(
|
||||
url='/example/{id}/sub/',
|
||||
action='get',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
)
|
||||
}
|
||||
)},
|
||||
'example-sub': {
|
||||
'list': coreapi.Link(
|
||||
url='/example/{id}/sub/',
|
||||
action='get',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -335,7 +334,7 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
|||
url='',
|
||||
title='Example API',
|
||||
content={
|
||||
'example': {
|
||||
'api-v1-example': {
|
||||
'create': coreapi.Link(
|
||||
url='/api/v1/example/',
|
||||
action='post',
|
||||
|
@ -352,16 +351,15 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
|||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
),
|
||||
'sub': {
|
||||
'list': coreapi.Link(
|
||||
url='/api/v1/example/{id}/sub/',
|
||||
action='get',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
)
|
||||
}
|
||||
)},
|
||||
'api-v1-example-sub': {
|
||||
'list': coreapi.Link(
|
||||
url='/api/v1/example/{id}/sub/',
|
||||
action='get',
|
||||
fields=[
|
||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -407,8 +405,11 @@ class TestSchemaGeneratorWithRestrictedViewSets(TestCase):
|
|||
class Test4605Regression(TestCase):
|
||||
def test_4605_regression(self):
|
||||
generator = SchemaGenerator()
|
||||
prefix = generator.determine_path_prefix([
|
||||
typical_path1 = generator.make_typical_path(
|
||||
'/api/v1/items/',
|
||||
)
|
||||
assert typical_path1 == 'api-v1-items'
|
||||
typical_path2 = generator.make_typical_path(
|
||||
'/auth/convert-token/'
|
||||
])
|
||||
assert prefix == '/'
|
||||
)
|
||||
assert typical_path2 == 'auth-convert-token'
|
||||
|
|
Loading…
Reference in New Issue
Block a user