Ejemplo n.º 1
0
def hottest_news():
    hacker_news_service = Service('hacker news', 'http')
    get_top = hacker_news_service.register('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty',
                                           transform=find_top)
    get_info = hacker_news_service.register('https://hacker-news.firebaseio.com/v0/item/{name}.json?print=pretty',
                                            transform=get_url)

    top_stories_query = get_top()
    if top_stories_query.errors:
        print(top_stories_query.errors)
        return
    detail_info_first = get_info(name=top_stories_query.data[0])
    if detail_info_first.errors:
        print(detail_info_first.errors)
        return
    print(detail_info_first.data)
    detail_info_second = get_info(name=top_stories_query.data[1])
    if detail_info_second.errors:
        print(detail_info_second.errors)
        return
    print(detail_info_second.data)
Ejemplo n.º 2
0
def hottest_news():
    hacker_news_service = Service('hacker news', 'http')
    get_top = hacker_news_service.register(
        'https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty',
        transform=find_top)
    get_info = hacker_news_service.register(
        'https://hacker-news.firebaseio.com/v0/item/{name}.json?print=pretty',
        transform=get_url)

    top_stories_query = get_top()
    if top_stories_query.errors:
        print(top_stories_query.errors)
        return
    detail_info_first = get_info(name=top_stories_query.data[0])
    if detail_info_first.errors:
        print(detail_info_first.errors)
        return
    print(detail_info_first.data)
    detail_info_second = get_info(name=top_stories_query.data[1])
    if detail_info_second.errors:
        print(detail_info_second.errors)
        return
    print(detail_info_second.data)
Ejemplo n.º 3
0
def test_service_register_method():
    multi_resource_service = Service('members', protocols.HTTP)
    assert hasattr(multi_resource_service, 'register')
    get_all_users = multi_resource_service.register('get all users')
    assert hasattr(get_all_users, '__call__')
Ejemplo n.º 4
0
def test_service_register_method():
    multi_resource_service = Service('members', protocols.HTTP)
    assert hasattr(multi_resource_service, 'register')
    get_all_users = multi_resource_service.register('get all users')
    assert hasattr(get_all_users, '__call__')