• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test.cassette函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.cassette函数的典型用法代码示例。如果您正苦于以下问题:Python cassette函数的具体用法?Python cassette怎么用?Python cassette使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cassette函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_should_get_by_scopus

def test_should_get_by_scopus():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/get_catalog_by_identifier/get_by_scopus.yaml'):
        doc = session.catalog.by_identifier(scopus='2-s2.0-41249100408')

        assert_core_view(doc)
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:7,代码来源:test_get_catalog_by_identifier.py


示例2: test_should_get_core_view

def test_should_get_core_view():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/get_catalog_by_id/get_core_view.yaml'):
        doc = session.catalog.get('5cd8328e-febe-3299-8e26-cf6ab2c07f0f')

        assert_core_view(doc)
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:7,代码来源:test_get_catalog_by_id.py


示例3: test_should_get_by_doi

def test_should_get_by_doi():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/get_catalog_by_identifier/get_by_doi.yaml'):
        doc = session.catalog.by_identifier(doi='10.1371/journal.pone.0000908')

        assert_core_view(doc)
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:7,代码来源:test_get_catalog_by_identifier.py


示例4: test_should_add_highlight

def test_should_add_highlight():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/annotations/add_annotation/add_highlight.yaml'):

        doc = create_document(session)
        file = doc.attach_file('fixtures/resources/files/basket.txt')

        top_left = Position.create(100, 200)
        bottom_right = Position.create(400, 500)
        bounding_box = BoundingBox.create(top_left, bottom_right, 1)
        color = Color.create(255, 125, 240)

        annotation = file.add_highlight([bounding_box], color)

        assert not annotation.text
        assert annotation.privacy_level == 'private'
        assert annotation.type == 'highlight'
        assert annotation.last_modified
        assert annotation.profile.id
        assert annotation.profile.display_name
        assert annotation.document().id == doc.id
        assert annotation.document().title == doc.title
        assert annotation.positions[0].top_left.x == 100
        assert annotation.positions[0].top_left.y == 200
        assert annotation.positions[0].bottom_right.x == 400
        assert annotation.positions[0].bottom_right.y == 500
        assert annotation.positions[0].page == 1
        assert annotation.color.r == 255
        assert annotation.color.g == 125
        assert annotation.color.b == 240
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:32,代码来源:test_add_annotation.py


示例5: test_should_page_through_documents

def test_should_page_through_documents():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/trash/list_trash/page_through_documents.yaml'):
        doc1 = create_document(session, 'title 1')
        doc1.move_to_trash()

        doc2 = create_document(session, 'title 2')
        doc2.move_to_trash()

        doc3 = create_document(session, 'title 3')
        doc3.move_to_trash()

        first_page = session.trash.list(page_size=2)
        assert len(first_page.items) == 2
        assert first_page.count == 3

        assert first_page.items[0].title == 'title 1'
        assert first_page.items[1].title == 'title 2'

        second_page = first_page.next_page
        assert len(second_page.items) == 1
        assert second_page.count == 3

        assert second_page.items[0].title == 'title 3'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:26,代码来源:test_list_trash.py


示例6: test_should_get_a_profile

def test_should_get_a_profile():
    session = get_user_session()

    with cassette('fixtures/resources/profiles/get_profile/get_profile.yaml'):
        profile = session.profiles.get('9930207c-c19f-3de0-b531-86bd4388fa94')

        assert profile.id == '9930207c-c19f-3de0-b531-86bd4388fa94'
        assert profile.first_name == 'Jenny'
        assert profile.last_name == 'Johnson'
        assert profile.display_name == 'Jenny Johnson'
        assert not profile.email
        assert profile.link == 'http://www.mendeley.com/profiles/jenny-johnson4/'
        assert not profile.research_interests
        assert profile.academic_status == 'Librarian'
        assert not profile.verified
        assert profile.user_type == 'normal'
        assert profile.created == arrow.get(2014, 8, 26, 15, 24, 45)

        assert profile.discipline.name == 'Humanities'
        assert not profile.discipline.subdisciplines

        assert not profile.photo.original
        assert profile.photo.standard == 'http://s3.amazonaws.com/mendeley-photos/awaiting.png'
        assert profile.photo.square == 'http://s3.amazonaws.com/mendeley-photos/awaiting_square.png'

        assert not profile.location
        assert not profile.education
        assert not profile.employment
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:28,代码来源:test_get_profile.py


示例7: test_should_page_through_group_documents

def test_should_page_through_group_documents():
    session = get_user_session()
    delete_all_group_documents()

    with cassette('fixtures/resources/documents/list_group_documents/page_through_documents.yaml'):
        create_group_document(session, 'title 1')
        create_group_document(session, 'title 2')
        create_group_document(session, 'title 3')

        first_page = session.groups.get('164d48fb-2343-332d-b566-1a4884a992e4').documents.list(page_size=2)
        assert len(first_page.items) == 2
        assert first_page.count == 3

        assert first_page.items[0].title == 'title 1'
        assert first_page.items[0].group.name == 'Basket weaving'

        assert first_page.items[1].title == 'title 2'
        assert first_page.items[1].group.name == 'Basket weaving'

        second_page = first_page.next_page
        assert len(second_page.items) == 1
        assert second_page.count == 3

        assert second_page.items[0].title == 'title 3'
        assert second_page.items[0].group.name == 'Basket weaving'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:25,代码来源:test_list_group_documents.py


示例8: test_should_get_a_group

def test_should_get_a_group():
    session = get_user_session()

    with cassette("fixtures/resources/groups/get_group/get_group.yaml"):
        group = session.groups.get("bcb12b97-db8a-3c1d-b696-d99ed4371175")

        assert group.id == "bcb12b97-db8a-3c1d-b696-d99ed4371175"
        assert group.name == "Python SDK Test Group"
        assert group.description == "Test group for the Mendeley Python SDK"
        assert group.disciplines == ["Computer and Information Science", "Humanities"]
        assert group.tags == ["python", "sdk"]
        assert group.webpage == "http://dev.mendeley.com"
        assert group.created == arrow.get(2014, 8, 27, 9, 40, 41)
        assert group.link == "http://www.mendeley.com/groups/4779311/python-sdk-test-group/"
        assert group.access_level == "public"
        assert group.role == "owner"

        assert (
            group.photo.original
            == "http://s3.amazonaws.com/mendeley-photos/a0/20/a020f9fd30af0029c059c45535ad231d3d0d055a.png"
        )
        assert (
            group.photo.standard
            == "http://s3.amazonaws.com/mendeley-photos/a0/20/a020f9fd30af0029c059c45535ad231d3d0d055a-standard.jpg"
        )
        assert (
            group.photo.square
            == "http://s3.amazonaws.com/mendeley-photos/a0/20/a020f9fd30af0029c059c45535ad231d3d0d055a-square.jpg"
        )

        assert group.owner.id == "9930207c-c19f-3de0-b531-86bd4388fa94"
        assert group.owner.display_name == "Jenny Johnson"
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:32,代码来源:test_get_group.py


示例9: test_should_iterate_through_annotations

def test_should_iterate_through_annotations():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/annotations/iter_annotations/iterate_through_annotations.yaml'):
        doc = create_document(session)

        file = doc.attach_file('fixtures/resources/files/basket.txt')

        top_left = Position.create(100, 200)
        bottom_right = Position.create(400, 500)
        bounding_box = BoundingBox.create(top_left, bottom_right, 1)
        color = Color.create(255, 125, 240)

        file.add_sticky_note("annotation 1", 100, 200, 1)
        doc.add_note("annotation 2")
        file.add_sticky_note("annotation 3", 100, 200, 1)
        file.add_highlight([bounding_box], color)

        annotations = list(session.annotations.iter(page_size=2))

        assert len(annotations) == 4
        assert not annotations[0].text
        assert annotations[1].text == 'annotation 3'
        assert annotations[2].text == 'annotation 1'
        assert annotations[3].text == 'annotation 2'
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:26,代码来源:test_iter_annotations.py


示例10: test_should_iterate_through_documents

def test_should_iterate_through_documents():
    session = get_user_session()
    delete_all_group_documents()

    with cassette('fixtures/resources/trash/iter_group_trash/iterate_through_documents.yaml'):
        doc1 = create_group_document(session, 'title 1')
        doc1.move_to_trash()

        doc2 = create_group_document(session, 'title 2')
        doc2.move_to_trash()

        doc3 = create_group_document(session, 'title 3')
        doc3.move_to_trash()

        docs = list(islice(session.groups.get('164d48fb-2343-332d-b566-1a4884a992e4').trash.iter(page_size=2), 3))

        assert len(docs) == 3
        assert docs[0].title == 'title 1'
        assert docs[0].group.name == 'Basket weaving'

        assert docs[1].title == 'title 2'
        assert docs[1].group.name == 'Basket weaving'

        assert docs[2].title == 'title 3'
        assert docs[2].group.name == 'Basket weaving'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:25,代码来源:test_iter_group_trash.py


示例11: test_should_throw_exception_on_incorrect_credentials

def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()

    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'), pytest.raises(InvalidClientError):
        auth.authenticate()
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:7,代码来源:test_client_credentials.py


示例12: test_should_update_highlight

def test_should_update_highlight():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/annotations/update_annotations/update_highlight.yaml'):
        doc = create_document(session)
        file = doc.attach_file('fixtures/resources/files/basket.txt')

        top_left = Position.create(400, 300)
        bottom_right = Position.create(400, 300)
        bounding_box = BoundingBox.create(top_left, bottom_right, 2)
        color = Color.create(255, 125, 240)
        updated_color = Color.create(123, 456, 222)

        annotation = file.add_highlight([bounding_box], color)

        patched_annotation = annotation.update(text="New text", positions=[bounding_box], color=updated_color)

        assert patched_annotation.text == "New text"
        assert patched_annotation.positions[0].top_left.x == 400
        assert patched_annotation.positions[0].top_left.y == 300
        assert patched_annotation.positions[0].bottom_right.x == 400
        assert patched_annotation.positions[0].bottom_right.y == 300
        assert patched_annotation.positions[0].page == 2
        assert patched_annotation.color.r == 123
        assert patched_annotation.color.g == 456
        assert patched_annotation.color.b == 222
        assert annotation.id == patched_annotation.id
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:28,代码来源:test_update_annotations.py


示例13: test_should_get_group_details

def test_should_get_group_details():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/documents/create_group_document/get_group_details.yaml'):
        doc = create_group_document(session)

        assert doc.group.name == 'Basket weaving'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:8,代码来源:test_create_group_document.py


示例14: test_should_lookup_by_filehash

def test_should_lookup_by_filehash():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/lookup/lookup_by_filehash.yaml'):
        doc = session.catalog.lookup(filehash='f9d3777596893362bbf49618e758d6b8a5271d04')

        assert doc.score == 100
        assert_core_view(doc)
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:8,代码来源:test_lookup.py


示例15: test_should_lookup_by_doi

def test_should_lookup_by_doi():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/lookup/lookup_by_doi.yaml'):
        doc = session.catalog.lookup(doi='10.1371/journal.pone.0000908')

        assert doc.score == 100
        assert_core_view(doc)
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:8,代码来源:test_lookup.py


示例16: test_should_get_authenticated_session

def test_should_get_authenticated_session():
    mendeley = configure_mendeley()
    auth = mendeley.start_client_credentials_flow()

    with cassette('fixtures/auth/client_credentials/get_authenticated_session.yaml'):
        session = auth.authenticate()

        assert session.token['access_token']
        assert session.host == 'https://api.mendeley.com'
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:9,代码来源:test_client_credentials.py


示例17: test_should_create_minimal_document

def test_should_create_minimal_document():
    session = get_user_session()
    delete_all_documents()

    with cassette('fixtures/resources/documents/create_document/create_minimal_document.yaml'):
        doc = session.documents.create('Underwater basket weaving', 'journal')

        assert doc.title == 'Underwater basket weaving'
        assert doc.type == 'journal'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:9,代码来源:test_create_document.py


示例18: test_should_iterate_through_search_results

def test_should_iterate_through_search_results():
    session = get_client_credentials_session()

    with cassette('fixtures/resources/catalog/iter_search/iterate_through_search_results.yaml'):
        docs = list(islice(session.catalog.search('mapreduce').iter(page_size=2), 3))

        assert docs[0].title == 'Rapid parallel genome indexing with MapReduce'
        assert docs[1].title == 'MapReduce'
        assert docs[2].title == 'Mumak: Map-Reduce Simulator'
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:9,代码来源:test_iter_search.py


示例19: test_should_throw_exception_on_incorrect_credentials

def test_should_throw_exception_on_incorrect_credentials():
    mendeley = configure_mendeley()
    mendeley.client_secret += '-invalid'
    auth = mendeley.start_client_credentials_flow()
    
    # We should never get an access token back
    # and the OAuth library should be unhappy about that
    with cassette('fixtures/auth/client_credentials/incorrect_credentials.yaml'), pytest.raises(MissingTokenError):
        auth.authenticate()
开发者ID:Mendeley,项目名称:mendeley-python-sdk,代码行数:9,代码来源:test_client_credentials.py


示例20: test_should_get_document_all_view

def test_should_get_document_all_view():
    session = get_user_session()
    delete_all_documents()

    with cassette("fixtures/resources/documents/get_document/get_document_all_view.yaml"):
        created_doc = create_document(session)

        doc = session.documents.get(created_doc.id, view="all")
        assert_all_document(doc)
开发者ID:CenterForOpenScience,项目名称:mendeley-python-sdk,代码行数:9,代码来源:test_get_document.py



注:本文中的test.cassette函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test.client_knobs函数代码示例发布时间:2022-05-27
下一篇:
Python test.assert_raises_message函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap