Exemple #1
0
def test_asset_retriever(get_reply, get_page):
    reply = json.loads(slurp_fixture('json/asset-retriever/assets-reply.json'))
    get_page.side_effect = [reply]
    get_reply.side_effect = [
        Mock(status_code=200,
             content='<...>',
             headers=Mock(get=Mock(return_value='image/png')))
    ] * 4

    asset_ids = [
        'bWTK9sYwEeW7AxLLCrgDQQ', 'VceKeChKEeaOMw70NkE3iw',
        'VcmGXShKEea4ehL5RXz3EQ', 'vdqUTz61Eea_CQ5dfWSAjQ'
    ]

    expected_output = [
        api.Asset(id="bWTK9sYwEeW7AxLLCrgDQQ",
                  name="M111.mp3",
                  type_name="audio",
                  url="url4",
                  content_type="image/png",
                  data="<...>"),
        api.Asset(id="VceKeChKEeaOMw70NkE3iw",
                  name="09_graph_decomposition_problems_1.pdf",
                  type_name="pdf",
                  url="url7",
                  content_type="image/png",
                  data="<...>"),
        api.Asset(id="VcmGXShKEea4ehL5RXz3EQ",
                  name="09_graph_decomposition_starter_files_1.zip",
                  type_name="generic",
                  url="url2",
                  content_type="image/png",
                  data="<...>"),
        api.Asset(id="vdqUTz61Eea_CQ5dfWSAjQ",
                  name="Capture.PNG",
                  type_name="image",
                  url="url9",
                  content_type="image/png",
                  data="<...>"),
    ]

    retriever = api.AssetRetriever(session=None)
    actual_output = retriever(asset_ids)

    assert expected_output == actual_output
Exemple #2
0
def test_debug_asset_retriever():
    pytest.skip()
    asset_ids = [
        'bWTK9sYwEeW7AxLLCrgDQQ', 'bXCx18YwEeWicwr5JH8fgw',
        'bX9X18YwEeW7AxLLCrgDQQ', 'bYHvf8YwEeWFNA5XwZEiOw',
        'tZmigMYxEeWFNA5XwZEiOw'
    ]
    asset_ids = asset_ids[0:5]

    more = ['VceKeChKEeaOMw70NkE3iw', 'VcmGXShKEea4ehL5RXz3EQ']

    print('session')
    session = create_session()
    retriever = api.AssetRetriever(session)
    #assets = retriever.get(asset_ids)
    assets = retriever(more)

    print(assets)