コード例 #1
0
    def get_endpoints(api_id=None, page=None, tags=None):
        if api_id:
            api = CRUD.getApi(api_id)
            endpoints = api.endpoints
        elif tags:
            endpoints = CRUD.getEndpoints(tags=tags)
        else:
            if page:
                endpoints = CRUD.getEndpoints(page=page)
            else:
                endpoints = CRUD.getEndpoints(page=1)

        j = endpoints_schema.dump(endpoints)
        return j
コード例 #2
0
def test_edit_api_by_id(mock_crud, context_api):
    print('\n=> Testing editing api by id')
    id = context_api.get('api_id')
    label = generate_random_string()
    url = generate_random_string()
    description = ' '.join([generate_random_string() for _ in range(5)])
    tags = ' '.join([generate_random_string() for _ in range(5)])
    code = CRUD.editApi(
        id,
        label=label,
        url=url,
        description=description,
        tags=tags
    )
    assert code>0
    api = CRUD.getApi(id)
    assert api.label == label
    assert api.url == url
    assert api.description == description
    assert set(tags.split()) == set([t.text for t in api.tags])
コード例 #3
0
 def get_api(id):
     api = CRUD.getApi(id)
     if not api: return {}
     j = api_schema.dump(api)
     return j
コード例 #4
0
def test_adding_api(mock_crud, context_api):
    print('\n=> Testing adding api to the database')
    api_id = context_api.get('api_id')
    assert api_id
    api = CRUD.getApi(api_id)
    assert api