Modify test code

This commit is contained in:
sol HYUN 2017-03-24 15:27:44 +09:00
parent 9b88ea7da7
commit eb80328356

View File

@ -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,8 +299,8 @@ class TestSchemaGenerator(TestCase):
fields=[
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
]
),
'sub': {
)},
'example-sub': {
'list': coreapi.Link(
url='/example/{id}/sub/',
action='get',
@ -310,7 +310,6 @@ class TestSchemaGenerator(TestCase):
)
}
}
}
)
assert schema == expected
@ -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,8 +351,8 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
fields=[
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
]
),
'sub': {
)},
'api-v1-example-sub': {
'list': coreapi.Link(
url='/api/v1/example/{id}/sub/',
action='get',
@ -363,7 +362,6 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
)
}
}
}
)
assert schema == expected
@ -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'