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

Python utils.assert_latest_log函数代码示例

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

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



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

示例1: test_deletes_private_node_pointer_logged_in_contributor

 def test_deletes_private_node_pointer_logged_in_contributor(
         self, app, user, private_project, private_url):
     with assert_latest_log(NodeLog.POINTER_REMOVED, private_project):
         res = app.delete(private_url, auth=user.auth)
         private_project.reload()  # Update the model to reflect changes made by post request
         assert res.status_code == 204
         assert len(private_project.nodes_pointer) == 0
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:7,代码来源:test_node_links_detail.py


示例2: test_deletes_public_node_pointer_succeeds_as_owner

 def test_deletes_public_node_pointer_succeeds_as_owner(self, app, user, public_project, public_pointer, public_url):
     with assert_latest_log(NodeLog.POINTER_REMOVED, public_project):
         node_count_before = len(public_project.nodes_pointer)
         res = app.delete(public_url, auth=user.auth)
         public_project.reload()
         assert res.status_code == 204
         assert node_count_before - 1 == len(public_project.nodes_pointer)
开发者ID:adlius,项目名称:osf.io,代码行数:7,代码来源:test_node_links_detail.py


示例3: test_move_top_contributor_down_one_and_also_log

 def test_move_top_contributor_down_one_and_also_log(
         self, app, user, contribs, project, contrib_user_id, url_contrib_base):
     with assert_latest_log(NodeLog.CONTRIB_REORDERED, project):
         contributor_to_move = contribs[0]._id
         contributor_id = '{}-{}'.format(project._id, contributor_to_move)
         former_second_contributor = contribs[1]
         url = '{}{}/'.format(url_contrib_base, contributor_to_move)
         data = {
             'data': {
                 'id': contributor_id,
                 'type': 'contributors',
                 'attributes': {
                     'index': 1
                 }
             }
         }
         res_patch = app.patch_json_api(url, data, auth=user.auth)
         assert res_patch.status_code == 200
         project.reload()
         res = app.get(
             '/{}nodes/{}/contributors/'.format(API_BASE, project._id), auth=user.auth)
         assert res.status_code == 200
         contributor_list = res.json['data']
         assert contrib_user_id(contributor_list[1]) == contributor_to_move
         assert contrib_user_id(
             contributor_list[0]) == former_second_contributor._id
开发者ID:leb2dg,项目名称:osf.io,代码行数:26,代码来源:test_node_contributors_detail.py


示例4: test_bulk_creates_node_pointer_already_connected

    def test_bulk_creates_node_pointer_already_connected(
            self, app, user, public_project,
            public_pointer_project_one,
            public_pointer_project_two,
            public_url, public_payload):
        with assert_latest_log(NodeLog.POINTER_CREATED, public_project):
            res = app.post_json_api(
                public_url, public_payload,
                auth=user.auth, bulk=True)
            assert res.status_code == 201
            assert res.content_type == 'application/vnd.api+json'
            res_json = res.json['data']
            embedded = res_json[0]['embeds']['target_node']['data']['id']
            assert embedded == public_pointer_project_one._id

            embedded_two = res_json[1]['embeds']['target_node']['data']['id']
            assert embedded_two == public_pointer_project_two._id

            res = app.post_json_api(
                public_url, public_payload,
                auth=user.auth,
                expect_errors=True, bulk=True)
            assert res.status_code == 400
            assert 'Target Node \'{}\' already pointed to by \'{}\'.'.format(
                public_pointer_project_one._id,
                public_project._id
            ) in res.json['errors'][0]['detail']
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:27,代码来源:test_node_links_list.py


示例5: test_bulk_creates_node_pointer_to_itself

    def test_bulk_creates_node_pointer_to_itself(
            self, app, user, public_project, public_url):
        with assert_latest_log(NodeLog.POINTER_CREATED, public_project):
            point_to_itself_payload = {
                'data': [{
                    'type': 'node_links',
                    'relationships': {
                        'nodes': {
                            'data': {
                                'type': 'nodes',
                                'id': public_project._id
                            }
                        }
                    }
                }]
            }

            res = app.post_json_api(
                public_url, point_to_itself_payload,
                auth=user.auth, bulk=True)
            assert res.status_code == 201
            assert res.content_type == 'application/vnd.api+json'
            res_json = res.json['data']
            embedded = res_json[0]['embeds']['target_node']['data']['id']
            assert embedded == public_project._id
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:25,代码来源:test_node_links_list.py


示例6: test_create_node_pointer_errors

    def test_create_node_pointer_errors(self, app, user, user_two, public_project, user_two_project, public_pointer_project, public_url, private_url, make_payload):

    #   test_create_node_pointer_to_itself_unauthorized
        point_to_itself_payload = make_payload(id=public_project._id)
        res = app.post_json_api(public_url, point_to_itself_payload, auth=user_two.auth, expect_errors=True)
        assert res.status_code == 403
        assert 'detail' in res.json['errors'][0]

    #   test_create_node_pointer_already_connected
        with assert_latest_log(NodeLog.POINTER_CREATED, public_project):
            public_payload = make_payload(id=public_pointer_project._id)
            res = app.post_json_api(public_url, public_payload, auth=user.auth)
            assert res.status_code == 201
            assert res.content_type == 'application/vnd.api+json'
            res_json = res.json['data']
            embedded = res_json['embeds']['target_node']['data']['id']
            assert embedded == public_pointer_project._id

            res = app.post_json_api(public_url, public_payload, auth=user.auth, expect_errors=True)
            assert res.status_code == 400
            assert 'detail' in res.json['errors'][0]

    #   test_create_node_pointer_no_type
        payload = {
            'data': {
                'relationships': {
                    'nodes': {
                        'data': {
                            'id': user_two_project._id,
                            'type': 'nodes'
                        }
                    }
                }
            }
        }
        res = app.post_json_api(private_url, payload, auth=user.auth, expect_errors=True)
        assert res.status_code == 400
        assert res.json['errors'][0]['detail'] == 'This field may not be null.'
        assert res.json['errors'][0]['source']['pointer'] == '/data/type'

    #   test_create_node_pointer_incorrect_type
        payload = {
            'data': {
                'type': 'Wrong type.',
                'relationships': {
                    'nodes': {
                        'data': {
                            'id': user_two_project._id,
                            'type': 'nodes'
                        }
                    }
                }
            }
        }
        res = app.post_json_api(private_url, payload, auth=user.auth, expect_errors=True)
        assert res.status_code == 409
        assert res.json['errors'][0]['detail'] == 'This resource has a type of "node_links", but you set the json body\'s type field to "Wrong type.". You probably need to change the type field to match the resource\'s type.'
开发者ID:adlius,项目名称:osf.io,代码行数:57,代码来源:test_node_links_list.py


示例7: test_create_node_pointer_to_itself

 def test_create_node_pointer_to_itself(self, app, user, public_project, public_url, make_payload):
     with assert_latest_log(NodeLog.POINTER_CREATED, public_project):
         point_to_itself_payload = make_payload(id=public_project._id)
         res = app.post_json_api(public_url, point_to_itself_payload, auth=user.auth)
         res_json = res.json['data']
         assert res.status_code == 201
         assert res.content_type == 'application/vnd.api+json'
         embedded = res_json['embeds']['target_node']['data']['id']
         assert embedded == public_project._id
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_node_links_list.py


示例8: test_create_node_pointer_contributing_node_to_non_contributing_node

 def test_create_node_pointer_contributing_node_to_non_contributing_node(self, app, user, user_two, user_two_project, private_project, private_url, make_payload):
     with assert_latest_log(NodeLog.POINTER_CREATED, private_project):
         user_two_payload = make_payload(id=user_two_project._id)
         res = app.post_json_api(private_url, user_two_payload, auth=user.auth)
         assert res.status_code == 201
         assert res.content_type == 'application/vnd.api+json'
         res_json = res.json['data']
         embedded = res_json['embeds']['target_node']['data']['id']
         assert embedded == user_two_project._id
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_node_links_list.py


示例9: test_return_deleted_private_node_pointer

    def test_return_deleted_private_node_pointer(self, app, user, private_project, private_url):
        with assert_latest_log(NodeLog.POINTER_REMOVED, private_project):
            res = app.delete(private_url, auth=user.auth)
            private_project.reload()  # Update the model to reflect changes made by post request
            assert res.status_code == 204

        #check that deleted pointer can not be returned
        res = app.get(private_url, auth=user.auth, expect_errors=True)
        assert res.status_code == 404
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_node_links_detail.py


示例10: test_bulk_deletes_public_node_pointers_succeeds_as_owner

    def test_bulk_deletes_public_node_pointers_succeeds_as_owner(self, app, user, public_project, public_url, public_payload):
        with assert_latest_log(NodeLog.POINTER_REMOVED, public_project):
            node_count_before = len(public_project.nodes_pointer)
            res = app.delete_json_api(public_url, public_payload, auth=user.auth, bulk=True)
            public_project.reload()
            assert res.status_code == 204
            assert node_count_before - 2 == len(public_project.nodes_pointer)

            public_project.reload()
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_node_links_list.py


示例11: test_bulk_creates_private_node_pointer_logged_in_contributor

    def test_bulk_creates_private_node_pointer_logged_in_contributor(self, app, user, private_project, private_payload, private_pointer_project_one, private_pointer_project_two, private_url):
        with assert_latest_log(NodeLog.POINTER_CREATED, private_project):
            res = app.post_json_api(private_url, private_payload, auth=user.auth, bulk=True)
            assert res.status_code == 201
            res_json = res.json['data']
            embedded = res_json[0]['embeds']['target_node']['data']['id']
            assert embedded == private_pointer_project_one._id

            embedded = res_json[1]['embeds']['target_node']['data']['id']
            assert embedded == private_pointer_project_two._id
            assert res.content_type == 'application/vnd.api+json'
开发者ID:adlius,项目名称:osf.io,代码行数:11,代码来源:test_node_links_list.py


示例12: test_return_bulk_deleted_private_node_pointer

    def test_return_bulk_deleted_private_node_pointer(self, app, user, private_project, private_pointer_one, private_url, private_payload):
        with assert_latest_log(NodeLog.POINTER_REMOVED, private_project):
            res = app.delete_json_api(private_url, private_payload, auth=user.auth, bulk=True)
            private_project.reload()  # Update the model to reflect changes made by post request
            assert res.status_code == 204

            pointer_url = '/{}nodes/{}/node_links/{}/'.format(API_BASE, private_project._id, private_pointer_one._id)

            #check that deleted pointer can not be returned
            res = app.get(pointer_url, auth=user.auth, expect_errors=True)
            assert res.status_code == 404
开发者ID:adlius,项目名称:osf.io,代码行数:11,代码来源:test_node_links_list.py


示例13: test_tags_add_and_remove_properly

 def test_tags_add_and_remove_properly(
         self, app, user_admin, registration_public,
         new_tag_payload_public, url_registration_public):
     with assert_latest_log(NodeLog.TAG_ADDED, registration_public):
         res = app.patch_json_api(
             url_registration_public,
             new_tag_payload_public,
             auth=user_admin.auth)
         assert res.status_code == 200
         # Ensure adding tag data is correct from the PATCH response
         assert len(res.json['data']['attributes']['tags']) == 1
         assert res.json['data']['attributes']['tags'][0] == 'new-tag'
     with assert_latest_log(NodeLog.TAG_REMOVED, registration_public), assert_latest_log(NodeLog.TAG_ADDED, registration_public, 1):
         # Ensure removing and adding tag data is correct from the PATCH
         # response
         res = app.patch_json_api(
             url_registration_public,
             {
                 'data': {
                     'id': registration_public._id,
                     'type': 'registrations',
                     'attributes': {'tags': ['newer-tag']}
                 }
             }, auth=user_admin.auth)
         assert res.status_code == 200
         assert len(res.json['data']['attributes']['tags']) == 1
         assert res.json['data']['attributes']['tags'][0] == 'newer-tag'
     with assert_latest_log(NodeLog.TAG_REMOVED, registration_public):
         # Ensure removing tag data is correct from the PATCH response
         res = app.patch_json_api(
             url_registration_public,
             {
                 'data': {
                     'id': registration_public._id,
                     'type': 'registrations',
                     'attributes': {'tags': []}
                 }
             }, auth=user_admin.auth)
         assert res.status_code == 200
         assert len(res.json['data']['attributes']['tags']) == 0
开发者ID:aaxelb,项目名称:osf.io,代码行数:40,代码来源:test_registration_detail.py


示例14: test_creates_public_node_pointer_logged_in

    def test_creates_public_node_pointer_logged_in(self, app, user, user_two, public_project, public_pointer_project, public_url, make_payload):
        public_payload = make_payload(id=public_pointer_project._id)
        with assert_latest_log(NodeLog.POINTER_CREATED, public_project):
            res = app.post_json_api(public_url, public_payload, auth=user_two.auth, expect_errors=True)
            assert res.status_code == 403
            assert 'detail' in res.json['errors'][0]

            res = app.post_json_api(public_url, public_payload, auth=user.auth)
            assert res.status_code == 201
            assert res.content_type == 'application/vnd.api+json'
            res_json = res.json['data']
            embedded = res_json['embeds']['target_node']['data']['id']
            assert embedded == public_pointer_project._id
开发者ID:adlius,项目名称:osf.io,代码行数:13,代码来源:test_node_links_list.py


示例15: test_remove_self_contributor_not_unique_admin

    def test_remove_self_contributor_not_unique_admin(
            self, app, user, user_write_contrib, preprint, url_user):
        with assert_latest_log(PreprintLog.CONTRIB_REMOVED, preprint):
            preprint.add_permission(
                user_write_contrib,
                permissions.ADMIN,
                save=True)

            res = app.delete(url_user, auth=user.auth)
            assert res.status_code == 204

            preprint.reload()
            assert user not in preprint.contributors
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:13,代码来源:test_preprint_contributors_detail.py


示例16: test_remove_contributor_admin

    def test_remove_contributor_admin(
            self, app, user, user_write_contrib,
            project, url_user_write_contrib):
        with assert_latest_log(NodeLog.CONTRIB_REMOVED, project):
            # Disconnect contributor_removed so that we don't check in files
            # We can remove this when StoredFileNode is implemented in
            # osf-models
            with disconnected_from_listeners(contributor_removed):
                res = app.delete(url_user_write_contrib, auth=user.auth)
            assert res.status_code == 204

            project.reload()
            assert user_write_contrib not in project.contributors
开发者ID:leb2dg,项目名称:osf.io,代码行数:13,代码来源:test_node_contributors_detail.py


示例17: test_change_contributor_bibliographic

    def test_change_contributor_bibliographic(
            self, app, user, contrib, project, url_contrib):
        contrib_id = '{}-{}'.format(project._id, contrib._id)
        with assert_latest_log(NodeLog.MADE_CONTRIBUTOR_INVISIBLE, project):
            data = {
                'data': {
                    'id': contrib_id,
                    'type': 'contributors',
                    'attributes': {
                        'bibliographic': False
                    }
                }
            }
            res = app.put_json_api(url_contrib, data, auth=user.auth)
            assert res.status_code == 200
            attributes = res.json['data']['attributes']
            assert not attributes['bibliographic']

            project.reload()
            assert not project.get_visible(contrib)

        with assert_latest_log(NodeLog.MADE_CONTRIBUTOR_VISIBLE, project):
            data = {
                'data': {
                    'id': contrib_id,
                    'type': 'contributors',
                    'attributes': {
                        'bibliographic': True
                    }
                }
            }
            res = app.put_json_api(url_contrib, data, auth=user.auth)
            assert res.status_code == 200
            attributes = res.json['data']['attributes']
            assert attributes['bibliographic']

            project.reload()
            assert project.get_visible(contrib)
开发者ID:leb2dg,项目名称:osf.io,代码行数:38,代码来源:test_node_contributors_detail.py


示例18: test_change_contributor_permission_and_bibliographic

    def test_change_contributor_permission_and_bibliographic(
            self, app, user, contrib, project, url_contrib):
        with assert_latest_log(NodeLog.PERMISSIONS_UPDATED, project, 1), assert_latest_log(NodeLog.MADE_CONTRIBUTOR_INVISIBLE, project):
            contrib_id = '{}-{}'.format(project._id, contrib._id)
            data = {
                'data': {
                    'id': contrib_id,
                    'type': 'contributors',
                    'attributes': {
                        'permission': permissions.READ,
                        'bibliographic': False
                    }
                }
            }
            res = app.put_json_api(url_contrib, data, auth=user.auth)
            assert res.status_code == 200
            attributes = res.json['data']['attributes']
            assert attributes['permission'] == permissions.READ
            assert not attributes['bibliographic']

            project.reload()
            assert project.get_permissions(contrib) == [permissions.READ]
            assert not project.get_visible(contrib)
开发者ID:leb2dg,项目名称:osf.io,代码行数:23,代码来源:test_node_contributors_detail.py


示例19: test_change_admin_self_with_other_admin

    def test_change_admin_self_with_other_admin(
            self, app, user, contrib, project, url_creator):
        with assert_latest_log(NodeLog.PERMISSIONS_UPDATED, project):
            project.add_permission(contrib, permissions.ADMIN, save=True)
            contrib_id = '{}-{}'.format(project._id, user._id)
            data = {
                'data': {
                    'id': contrib_id,
                    'type': 'contributors',
                    'attributes': {
                        'permission': permissions.WRITE,
                        'bibliographic': True
                    }
                }
            }
            res = app.put_json_api(url_creator, data, auth=user.auth)
            assert res.status_code == 200
            attributes = res.json['data']['attributes']
            assert attributes['permission'] == permissions.WRITE

            project.reload()
            assert project.get_permissions(user) == [
                permissions.READ, permissions.WRITE]
开发者ID:leb2dg,项目名称:osf.io,代码行数:23,代码来源:test_node_contributors_detail.py


示例20: test_remove_self_non_admin

    def test_remove_self_non_admin(
            self, app, user_non_contrib,
            project, url_user_non_contrib):
        with assert_latest_log(NodeLog.CONTRIB_REMOVED, project):
            project.add_contributor(
                user_non_contrib,
                permissions=[
                    permissions.READ,
                    permissions.WRITE],
                visible=True,
                save=True)

            # Disconnect contributor_removed so that we don't check in files
            # We can remove this when StoredFileNode is implemented in
            # osf-models
            with disconnected_from_listeners(contributor_removed):
                res = app.delete(
                    url_user_non_contrib,
                    auth=user_non_contrib.auth)
            assert res.status_code == 204

            project.reload()
            assert user_non_contrib not in project.contributors
开发者ID:leb2dg,项目名称:osf.io,代码行数:23,代码来源:test_node_contributors_detail.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.assert_message_in_errors函数代码示例发布时间:2022-05-27
下一篇:
Python utils.assert_error_message_equal函数代码示例发布时间: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