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/',
|
url='/example/custom_list_action/',
|
||||||
action='get'
|
action='get'
|
||||||
),
|
),
|
||||||
'custom_list_action_multiple_methods': {
|
|
||||||
'read': coreapi.Link(
|
|
||||||
url='/example/custom_list_action_multiple_methods/',
|
|
||||||
action='get'
|
|
||||||
)
|
|
||||||
},
|
|
||||||
'read': coreapi.Link(
|
'read': coreapi.Link(
|
||||||
url='/example/{id}/',
|
url='/example/{id}/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -122,6 +116,12 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
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())
|
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(
|
'update': coreapi.Link(
|
||||||
url='/example/{id}/',
|
url='/example/{id}/',
|
||||||
action='put',
|
action='put',
|
||||||
|
@ -213,8 +188,33 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
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
|
assert response.data == expected
|
||||||
|
@ -299,8 +299,8 @@ class TestSchemaGenerator(TestCase):
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||||
]
|
]
|
||||||
),
|
)},
|
||||||
'sub': {
|
'example-sub': {
|
||||||
'list': coreapi.Link(
|
'list': coreapi.Link(
|
||||||
url='/example/{id}/sub/',
|
url='/example/{id}/sub/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -310,7 +310,6 @@ class TestSchemaGenerator(TestCase):
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
assert schema == expected
|
assert schema == expected
|
||||||
|
|
||||||
|
@ -335,7 +334,7 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
||||||
url='',
|
url='',
|
||||||
title='Example API',
|
title='Example API',
|
||||||
content={
|
content={
|
||||||
'example': {
|
'api-v1-example': {
|
||||||
'create': coreapi.Link(
|
'create': coreapi.Link(
|
||||||
url='/api/v1/example/',
|
url='/api/v1/example/',
|
||||||
action='post',
|
action='post',
|
||||||
|
@ -352,8 +351,8 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||||
]
|
]
|
||||||
),
|
)},
|
||||||
'sub': {
|
'api-v1-example-sub': {
|
||||||
'list': coreapi.Link(
|
'list': coreapi.Link(
|
||||||
url='/api/v1/example/{id}/sub/',
|
url='/api/v1/example/{id}/sub/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -363,7 +362,6 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
assert schema == expected
|
assert schema == expected
|
||||||
|
|
||||||
|
@ -407,8 +405,11 @@ class TestSchemaGeneratorWithRestrictedViewSets(TestCase):
|
||||||
class Test4605Regression(TestCase):
|
class Test4605Regression(TestCase):
|
||||||
def test_4605_regression(self):
|
def test_4605_regression(self):
|
||||||
generator = SchemaGenerator()
|
generator = SchemaGenerator()
|
||||||
prefix = generator.determine_path_prefix([
|
typical_path1 = generator.make_typical_path(
|
||||||
'/api/v1/items/',
|
'/api/v1/items/',
|
||||||
|
)
|
||||||
|
assert typical_path1 == 'api-v1-items'
|
||||||
|
typical_path2 = generator.make_typical_path(
|
||||||
'/auth/convert-token/'
|
'/auth/convert-token/'
|
||||||
])
|
)
|
||||||
assert prefix == '/'
|
assert typical_path2 == 'auth-convert-token'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user