当前位置: 首页>>代码示例>>Python>>正文


Python utils.assert_latest_log函数代码示例

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


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


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