本文整理匯總了Python中applications.zcomx.modules.books.Book.from_query方法的典型用法代碼示例。如果您正苦於以下問題:Python Book.from_query方法的具體用法?Python Book.from_query怎麽用?Python Book.from_query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類applications.zcomx.modules.books.Book
的用法示例。
在下文中一共展示了Book.from_query方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUpClass
# 需要導入模塊: from applications.zcomx.modules.books import Book [as 別名]
# 或者: from applications.zcomx.modules.books.Book import from_query [as 別名]
def setUpClass(cls):
# C0103: *Invalid name "%%s" (should match %%s)*
# pylint: disable=C0103
# Get the data the tests will use.
email = web.username
query = (db.auth_user.email == email)
cls._user = db(query).select(limitby=(0, 1)).first()
if not cls._user:
msg = 'No user with email: {e}'.format(e=email)
print msg
raise SyntaxError(msg)
query = db.creator.auth_user_id == cls._user.id
cls._creator = Creator.from_query(query)
if not cls._creator:
msg = 'No creator with email: {e}'.format(e=email)
print msg
raise SyntaxError(msg)
cls._creator_as_dict = cls._creator.as_dict()
query = (db.book.creator_id == cls._creator.id) & \
(db.book.name_for_url == 'TestDoNotDelete-001')
cls._book = Book.from_query(query)
cls._book_page = get_page(cls._book, page_no='first')
id_max = db.optimize_img_log.id.max()
cls._max_optimize_img_log_id = \
db(db.optimize_img_log).select(id_max)[0][id_max]
cls._test_data_dir = os.path.join(request.folder, 'private/test/data/')
示例2: test__download
# 需要導入模塊: from applications.zcomx.modules.books import Book [as 別名]
# 或者: from applications.zcomx.modules.books.Book import from_query [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))
示例3: setUpClass
# 需要導入模塊: from applications.zcomx.modules.books import Book [as 別名]
# 或者: from applications.zcomx.modules.books.Book import from_query [as 別名]
def setUpClass(cls):
# C0103: *Invalid name "%%s" (should match %%s)*
# pylint: disable=C0103
# Get the data the tests will use.
email = web.username
query = (db.auth_user.email == email)
cls._user = db(query).select(limitby=(0, 1)).first()
if not cls._user:
raise SyntaxError('No user with email: {e}'.format(e=email))
cls._creator = Creator.from_key(dict(auth_user_id=cls._user.id))
if not cls._creator:
raise SyntaxError('No creator with email: {e}'.format(e=email))
query = db.book.creator_id == cls._creator.id
cls._book = Book.from_query(query)
if not cls._book:
raise SyntaxError('No book for creator with email: {e}'.format(
e=email))
cls._server_ip = web.server_ip()