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


Python Book.from_key方法代码示例

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


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

示例1: setUpClass

# 需要导入模块: from applications.zcomx.modules.books import Book [as 别名]
# 或者: from applications.zcomx.modules.books.Book import from_key [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: do_test_random

# 需要导入模块: from applications.zcomx.modules.books import Book [as 别名]
# 或者: from applications.zcomx.modules.books.Book import from_key [as 别名]
        def do_test_random(request_vars):
            """Run test."""
            self._request.vars = request_vars
            router = Router(db, self._request, auth)
            router.page_not_found()

            self.assertTrue('urls' in router.view_dict)
            self.assertTrue('suggestions' in router.view_dict['urls'])
            labels = [
                x['label'] for x in router.view_dict['urls']['suggestions']]
            self.assertEqual(
                labels,
                ['Cartoonist page:', 'Book page:', 'Read:']
            )
            self.assertEqual(
                router.view_dict['urls']['invalid'],
                'http://www.domain.com/path/to/page'
            )
            self.assertEqual(router.view, 'errors/page_not_found.html')
            book_url = router.view_dict['urls']['suggestions'][1]['url']
            # http://127.0.0.1:8000/FirstLast/MyBook
            unused_scheme, _, unused_url, creator_for_url, book_for_url = \
                book_url.split('/')

            got = Creator.from_key(dict(
                name_for_url=urllib.unquote(creator_for_url)))
            self.assertTrue(got)
            got = Book.from_key(dict(
                name_for_url=urllib.unquote(book_for_url)))
            self.assertTrue(got)
            self.assertTrue(got.release_date is not None)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:33,代码来源:test_routing.py

示例3: test__download

# 需要导入模块: from applications.zcomx.modules.books import Book [as 别名]
# 或者: from applications.zcomx.modules.books.Book import from_key [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

示例4: setUp

# 需要导入模块: from applications.zcomx.modules.books import Book [as 别名]
# 或者: from applications.zcomx.modules.books.Book import from_key [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


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