python类use_cassette()的实例源码

content_type_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_update_content_type(self):
        content_type = CLIENT.content_types(PLAYGROUND_SPACE).find('foo')

        self.assertEqual(content_type.name, 'something else')

        with vcr.use_cassette('fixtures/content_type/update.yaml'):
            content_type.name = 'foo'
            content_type.save()

        self.assertEqual(content_type.name, 'foo')
content_type_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_delete_content_type(self):
        content_type = CLIENT.content_types(PLAYGROUND_SPACE).find('45JdPK7wbCQwecKOAyqcw0')

        with vcr.use_cassette('fixtures/content_type/delete.yaml'):
            content_type.delete()

        with vcr.use_cassette('fixtures/content_type/not_found.yaml'):
            with self.assertRaises(NotFoundError):
                CLIENT.content_types(PLAYGROUND_SPACE).find('45JdPK7wbCQwecKOAyqcw0')
content_type_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def test_publish_content_type(self):
        content_type = CLIENT.content_types(PLAYGROUND_SPACE).find('1JzBeA5EcEcyKUaqGeqImy')

        published_counter = getattr(content_type, 'published_counter', 0)

        with vcr.use_cassette('fixtures/content_type/publish.yaml'):
            content_type.publish()

        self.assertEqual(content_type.published_counter, published_counter + 1)
        self.assertTrue(content_type.is_published)
personal_access_token_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_personal_access_token_revoke(self):
        token = CLIENT.personal_access_tokens().find('6ZKYaf1m2PyFU7Olcnw5jK')

        self.assertFalse(token.is_revoked)

        with vcr.use_cassette('fixtures/pat/revoke.yaml'):
            token = CLIENT.personal_access_tokens().revoke('6ZKYaf1m2PyFU7Olcnw5jK')

            self.assertTrue(token.is_revoked)
editor_interface_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_editor_interface_update(self):
        editor_interface = CLIENT.editor_interfaces(PLAYGROUND_SPACE, 'foo').find()

        self.assertEqual(editor_interface.controls[0]['widgetId'], 'multiLine')

        with vcr.use_cassette('fixtures/editor_interface/update.yaml'):
            editor_interface.controls[0]['widgetId'] = 'singleLine'
            editor_interface.save()

        self.assertEqual(editor_interface.controls[0]['widgetId'], 'singleLine')
api_key_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_update_api_key(self):
        api_key = CLIENT.api_keys(PLAYGROUND_SPACE).find('42sVZNadpFAje7EFwHOfVY')

        with vcr.use_cassette('fixtures/api_key/update.yaml'):
            api_key.name = 'Not Test Key'
            api_key.save()

        self.assertEqual(api_key.name, 'Not Test Key')
api_key_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_delete_api_key(self):
        api_key = CLIENT.api_keys(PLAYGROUND_SPACE).find('42sVZNadpFAje7EFwHOfVY')

        with vcr.use_cassette('fixtures/api_key/delete.yaml'):
            api_key.delete()

        with vcr.use_cassette('fixtures/api_key/not_found.yaml'):
            with self.assertRaises(NotFoundError):
                CLIENT.api_keys(PLAYGROUND_SPACE).find('42sVZNadpFAje7EFwHOfVY')
entry_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_delete_entry(self):
        entry = CLIENT.entries(PLAYGROUND_SPACE).find('4RToqNcBfW6MAK0UGU0qWc')

        with vcr.use_cassette('fixtures/entry/delete.yaml'):
            entry.delete()

        with vcr.use_cassette('fixtures/entry/not_found.yaml'):
            with self.assertRaises(NotFoundError):
                CLIENT.entries(PLAYGROUND_SPACE).find('4RToqNcBfW6MAK0UGU0qWc')
entry_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_unpublish_entry(self):
        entry = CLIENT.entries(PLAYGROUND_SPACE).find('5gQdVmPHKwIk2MumquYwOu')

        with vcr.use_cassette('fixtures/entry/unpublish.yaml'):
            entry.unpublish()

        self.assertFalse(entry.is_published)
entry_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_update_entry(self):
        entry = CLIENT.entries(PLAYGROUND_SPACE).find('1dYTHwMZlU2wm88SA8I2Q0')

        self.assertEqual(entry.name, 'foobar')

        with vcr.use_cassette('fixtures/entry/update.yaml'):
            entry.name = 'something else'
            entry.save()

        self.assertEqual(entry.name, 'something else')

    # Issues
entry_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_update_entry_field_with_undefined_but_non_present_field(self):
        entry = None
        with vcr.use_cassette('fixtures/entry/undefined_fields.yaml'):
            entry = CLIENT.entries(PLAYGROUND_SPACE).find('33uj74Wln2Oc02CAyEY8CK')

            self.assertEqual(entry.fields(), {})

            with vcr.use_cassette('fixtures/entry/undefined_fields_non_present.yaml'):
                entry.non_existent = 'foo'

                self.assertEqual(entry.non_existent, 'foo')
                self.assertEqual(entry.fields(), {})
asset_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_update_asset(self):
        asset = CLIENT.assets(PLAYGROUND_SPACE).find('file3')

        with vcr.use_cassette('fixtures/asset/update.yaml'):
            asset.file['fileName'] = 'demo app image'
            asset.save()

        self.assertEqual(asset.file['fileName'], 'demo app image')
asset_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_delete_asset(self):
        asset = CLIENT.assets(PLAYGROUND_SPACE).find('file6')

        with vcr.use_cassette('fixtures/asset/delete.yaml'):
            asset.delete()

        with vcr.use_cassette('fixtures/asset/not_found.yaml'):
            with self.assertRaises(NotFoundError):
                CLIENT.assets(PLAYGROUND_SPACE).find('file6')
asset_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_publish_asset(self):
        asset = CLIENT.assets(PLAYGROUND_SPACE).find('file3')

        published_counter = getattr(asset, 'published_counter', 0)

        with vcr.use_cassette('fixtures/asset/publish.yaml'):
            asset.publish()

        self.assertEqual(asset.published_counter, published_counter + 1)
        self.assertTrue(asset.is_published)
asset_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def test_unpublish_asset(self):
        asset = CLIENT.assets(PLAYGROUND_SPACE).find('file3')

        with vcr.use_cassette('fixtures/asset/unpublish.yaml'):
            asset.unpublish()

        self.assertFalse(asset.is_published)
asset_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_archive_asset(self):
        asset = CLIENT.assets(PLAYGROUND_SPACE).find('file3')

        archived_version = getattr(asset, 'archived_version', asset.version)

        self.assertFalse(asset.is_archived)

        with vcr.use_cassette('fixtures/asset/archive.yaml'):
            asset.archive()

        self.assertEqual(asset.archived_version, archived_version)
        self.assertTrue(asset.is_archived)
webhook_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def test_update_webhook(self):
        webhook = CLIENT.webhooks(PLAYGROUND_SPACE).find('2xzNZ8gOsq0sz4ueoytkeW')

        with vcr.use_cassette('fixtures/webhook/update.yaml'):
            webhook.name = 'Not Klingon'
            webhook.save()

        self.assertEqual(webhook.name, 'Not Klingon')
webhook_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_delete_webhook(self):
        webhook = CLIENT.webhooks(PLAYGROUND_SPACE).find('2xzNZ8gOsq0sz4ueoytkeW')

        with vcr.use_cassette('fixtures/webhook/delete.yaml'):
            webhook.delete()

        with vcr.use_cassette('fixtures/webhook/not_found.yaml'):
            with self.assertRaises(NotFoundError):
                CLIENT.webhooks(PLAYGROUND_SPACE).find('2xzNZ8gOsq0sz4ueoytkeW')
content_type_entries_proxy_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def test_content_types_entries_proxy_delete(self):
        proxy = ContentTypeEntriesProxy(CLIENT, PLAYGROUND_SPACE, 'foo')

        proxy.delete('1zquSqZeokECU2Wike2cQi')

        with vcr.use_cassette('fixtures/entry/not_found_content_type.yaml'):
            with self.assertRaises(NotFoundError):
                proxy.find('1zquSqZeokECU2Wike2cQi')
space_test.py 文件源码 项目:contentful-management.py 作者: contentful 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_update_space(self):
        space = CLIENT.spaces().find('6sun6p8v2zr6')

        self.assertEqual(space.name, 'Create Test')

        with vcr.use_cassette('fixtures/space/update.yaml'):
            space.name = 'Update Test'
            space.save()

        self.assertEqual(space.name, 'Update Test')


问题


面经


文章

微信
公众号

扫码关注公众号