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


Python Creator.by_email方法代码示例

本文整理汇总了Python中applications.zcomx.modules.creators.Creator.by_email方法的典型用法代码示例。如果您正苦于以下问题:Python Creator.by_email方法的具体用法?Python Creator.by_email怎么用?Python Creator.by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在applications.zcomx.modules.creators.Creator的用法示例。


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

示例1: setUpClass

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
 def setUpClass(cls):
     # C0103: *Invalid name "%%s" (should match %%s)*
     # pylint: disable=C0103
     # Get the data the tests will use.
     cls._creator = Creator.by_email(web.username)
     cls._book = Book.from_key(dict(creator_id=cls._creator.id))
     cls._server_ip = web.server_ip()
开发者ID:zcomx,项目名称:zcomix.com,代码行数:9,代码来源:test_cbz.py

示例2: test__download

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
    def test__download(self):
        downloader = CBZDownloader()
        self.assertTrue(downloader)
        env = globals()
        request = env['request']

        def test_http(args, expect):
            request.args = List(args)
            try:
                downloader.download(request, db)
            except HTTP as http:
                self.assertEqual(http.status, expect['status'])
                if expect['status'] == 200:
                    self.assertEqual(
                        http.headers['Content-Type'],
                        'application/x-cbz'
                    )
                    self.assertEqual(
                        http.headers['Content-Disposition'],
                        'attachment; filename="{f}"'.format(
                            f=expect['filename'])
                    )
                    self.assertEqual(
                        http.headers['Content-Length'],
                        expect['size']
                    )

        # Find a book with a cbz.
        creator = Creator.by_email(web.username)
        query = (db.book.creator_id == creator.id) & \
            (db.book.cbz != None)

        book = Book.from_query(query)
        if not book:
            self.fail('Book by creator {c} with cbz not found.'.format(
                c=creator.email))

        test_http(
            [book.id],
            dict(
                status=200,
                filename=os.path.basename(book.cbz),
                size=os.stat(book.cbz).st_size,
            )
        )

        # Test invalids
        invalid_record_id = -1
        test_http([invalid_record_id], dict(status=404))

        # Find a book without a cbz.
        book = Book.from_key(dict(cbz=None))
        if book:
            test_http([book.id], dict(status=404))
开发者ID:zcomx,项目名称:zcomix.com,代码行数:56,代码来源:test_downloaders.py

示例3: test__by_email

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
    def test__by_email(self):
        # Doesn't exist
        self.assertRaises(LookupError, Creator.by_email, '_invalid_email_')

        # Auth user exists but no creator
        auth_user = self.add(AuthUser, dict(email='[email protected]'))
        self.assertRaises(LookupError, Creator.by_email, '[email protected]')

        creator = self.add(Creator, dict(auth_user_id=auth_user.id))
        got = Creator.by_email('[email protected]')
        self.assertEqual(got, creator)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:13,代码来源:test_creators.py

示例4: setUp

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
    def setUp(self):
        # W0212: *Access to a protected member %%s of a client class*
        # pylint: disable=W0212
        # Get a book from a creator with a paypal_email.
        self._creator = Creator.by_email(web.username)
        self._book = Book.from_key(dict(creator_id=self._creator.id))

        max_book_id = db.book.id.max()
        rows = db().select(max_book_id)
        if rows:
            self._invalid_book_id = rows[0][max_book_id] + 1
        else:
            self._invalid_book_id = 1
开发者ID:zcomx,项目名称:zcomix.com,代码行数:15,代码来源:test_downloads.py

示例5: setUpClass

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
    def setUpClass(cls):
        # Use an existing image to test with.
        creator = Creator.by_email(web.username)

        query = (db.book.release_date != None) & \
                (db.book.creator_id == creator.id) & \
                (db.book_page.page_no == 1)
        rows = db(query).select(
            db.book_page.image,
            left=[
                db.book.on(db.book_page.book_id == db.book.id),
            ],
            limitby=(0, 1),
        )
        if not rows:
            cls.fail('Unable to get image to test with.')
        cls._test_image = rows[0]['image']

        upload_img = UploadImage(db.book_page.image, cls._test_image)
        fullname = upload_img.fullname(size='web')
        cls._test_image_bytes = ImageDescriptor(fullname).size_bytes()
开发者ID:zcomx,项目名称:zcomix.com,代码行数:23,代码来源:test_tweeter.py

示例6: setUpClass

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
 def setUpClass(cls):
     # C0103: *Invalid name "%%s" (should match %%s)*
     # pylint: disable=C0103
     # Get the data the tests will use.
     cls._creator = Creator.by_email(web.username)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:7,代码来源:test_creators.py

示例7: test__image_as_json

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import by_email [as 别名]
    def test__image_as_json(self):
        creator = Creator.by_email(web.username)

        for field in ['image', 'indicia_image']:
            if creator[field]:
                filename, fullname = db.creator[field].retrieve(
                    creator[field],
                    nameonly=True,
                )
            if not creator[field] or not os.path.exists(fullname):
                stored_filename = store(
                    db.creator[field],
                    self._prep_image('file.jpg'),
                    resizer=ResizerQuick,
                )
                data = {field: stored_filename}
                creator = Creator.from_updated(creator, data)

        self.assertTrue(creator)

        def do_test(image, expect):
            self.assertTrue('files' in image.keys())
            self.assertEqual(len(image['files']), 1)
            self.assertEqual(
                image['files'][0],
                {
                    'name': expect.filename,
                    'size': expect.size,
                    'url': expect.down_url,
                    'thumbnailUrl': expect.thumb,
                    'deleteUrl': expect.delete_url,
                    'deleteType': 'DELETE',
                }
            )

        # Test creator.image
        image_json = image_as_json(creator)
        expect = Storage({})
        filename, fullname = db.creator.image.retrieve(
            creator.image,
            nameonly=True,
        )

        expect.filename = filename
        expect.size = os.stat(fullname).st_size
        expect.down_url = '/images/download/{img}'.format(
            img=creator.image)
        expect.thumb = '/images/download/{img}?size=web'.format(
            img=creator.image)
        expect.delete_url = '/login/creator_img_handler/image'

        do_test(json.loads(image_json), expect)

        # Test creator.indicia_image
        image_json = image_as_json(creator, field='indicia_image')
        expect = Storage({})
        filename, fullname = db.creator.indicia_image.retrieve(
            creator.indicia_image,
            nameonly=True,
        )
        expect.filename = filename
        expect.size = os.stat(fullname).st_size
        expect.down_url = '/images/download/{img}'.format(
            img=creator.indicia_image)
        expect.thumb = '/images/download/{img}?size=web'.format(
            img=creator.indicia_image)
        expect.delete_url = '/login/creator_img_handler/indicia_image'

        do_test(json.loads(image_json), expect)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:71,代码来源:test_creators.py


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