def test_default_actions_and_single_custom_action_two_methods(self):
     schema = coreapi.Document(
         url='',
         title='Example API',
         content={
             'users': {
                 'create': coreapi.Link(
                     url='/users/',
                     action='post',
                     fields=[]
                 ),
                 'list': coreapi.Link(
                     url='/users/',
                     action='get',
                     fields=[]
                 ),
                 'read': coreapi.Link(
                     url='/users/{id}/',
                     action='get',
                     fields=[
                         coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                     ]
                 ),
                 'update': coreapi.Link(
                     url='/users/{id}/',
                     action='patch',
                     fields=[
                         coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                     ]
                 ),
                 'friends': {
                     'list': coreapi.Link(
                         url='/users/{id}/friends',
                         action='get',
                         fields=[
                             coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                         ]
                     ),
                     'create': coreapi.Link(
                         url='/users/{id}/friends',
                         action='post',
                         fields=[
                             coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                         ]
                     )
                 }
             }
         }
     )
     section = schema['users']
     flat_links = schema_links(section)
     assert len(flat_links) is 6
     assert 'list' in flat_links
     assert 'create' in flat_links
     assert 'read' in flat_links
     assert 'update' in flat_links
     assert 'friends > list' in flat_links
     assert 'friends > create' in flat_links
 def test_schema_with_empty_links(self):
     schema = coreapi.Document(url='',
                               title='Example API',
                               content={'users': {
                                   'list': {}
                               }})
     section = schema['users']
     flat_links = schema_links(section)
     assert len(flat_links) is 0
 def test_multiple_nested_routes(self):
     schema = coreapi.Document(
         url='',
         title='Example API',
         content={
             'animals': {
                 'dog': {
                     'vet': {
                         'list':
                         coreapi.Link(url='/animals/dog/{id}/vet',
                                      action='get',
                                      fields=[
                                          coreapi.Field(
                                              'id',
                                              required=True,
                                              location='path',
                                              schema=coreschema.String())
                                      ])
                     },
                     'read':
                     coreapi.Link(url='/animals/dog/{id}',
                                  action='get',
                                  fields=[
                                      coreapi.Field(
                                          'id',
                                          required=True,
                                          location='path',
                                          schema=coreschema.String())
                                  ])
                 },
                 'cat': {
                     'list':
                     coreapi.Link(url='/animals/cat/',
                                  action='get',
                                  fields=[
                                      coreapi.Field(
                                          'id',
                                          required=True,
                                          location='path',
                                          schema=coreschema.String())
                                  ]),
                     'create':
                     coreapi.Link(url='/aniamls/cat',
                                  action='post',
                                  fields=[])
                 }
             }
         })
     section = schema['animals']
     flat_links = schema_links(section)
     assert len(flat_links) is 4
     assert 'cat > create' in flat_links
     assert 'cat > list' in flat_links
     assert 'dog > read' in flat_links
     assert 'dog > vet > list' in flat_links
 def test_schema_with_empty_links(self):
     schema = coreapi.Document(
         url='',
         title='Example API',
         content={
             'users': {
                 'list': {}
             }
         }
     )
     section = schema['users']
     flat_links = schema_links(section)
     assert len(flat_links) is 0
 def test_single_action(self):
     schema = coreapi.Document(url='',
                               title='Example API',
                               content={
                                   'users': {
                                       'list':
                                       coreapi.Link(url='/users/',
                                                    action='get',
                                                    fields=[])
                                   }
                               })
     section = schema['users']
     flat_links = schema_links(section)
     assert len(flat_links) is 1
     assert 'list' in flat_links
 def test_multiple_nested_routes(self):
     schema = coreapi.Document(
         url='',
         title='Example API',
         content={
             'animals': {
                 'dog': {
                     'vet': {
                         'list': coreapi.Link(
                             url='/animals/dog/{id}/vet',
                             action='get',
                             fields=[
                                 coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                             ]
                         )
                     },
                     'read': coreapi.Link(
                         url='/animals/dog/{id}',
                         action='get',
                         fields=[
                             coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                         ]
                     )
                 },
                 'cat': {
                     'list': coreapi.Link(
                         url='/animals/cat/',
                         action='get',
                         fields=[
                             coreapi.Field('id', required=True, location='path', schema=coreschema.String())
                         ]
                     ),
                     'create': coreapi.Link(
                         url='/aniamls/cat',
                         action='post',
                         fields=[]
                     )
                 }
             }
         }
     )
     section = schema['animals']
     flat_links = schema_links(section)
     assert len(flat_links) is 4
     assert 'cat > create' in flat_links
     assert 'cat > list' in flat_links
     assert 'dog > read' in flat_links
     assert 'dog > vet > list' in flat_links
 def test_single_action(self):
     schema = coreapi.Document(
         url='',
         title='Example API',
         content={
             'users': {
                 'list': coreapi.Link(
                     url='/users/',
                     action='get',
                     fields=[]
                 )
             }
         }
     )
     section = schema['users']
     flat_links = schema_links(section)
     assert len(flat_links) is 1
     assert 'list' in flat_links