本文整理汇总了Python中models.card.Card.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Card.insert方法的具体用法?Python Card.insert怎么用?Python Card.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.card.Card
的用法示例。
在下文中一共展示了Card.insert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_language
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_language(db_conn, cards_table):
"""
Expect a card to require a language.
"""
card, errors = Card.insert({
'previous_id': 'TJKL35',
'unit_id': 'RUF531',
'name': 'What is?',
'kind': 'video'
})
assert len(errors) == 0
card['language'] = 'en'
示例2: test_unit_id
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_unit_id(db_conn, cards_table):
"""
Expect a card to require a unit id.
"""
card, errors = Card.insert({
'previous_id': 'TJKL35',
'language': 'en',
'name': 'What is?',
'kind': 'video'
})
assert len(errors) == 1
card['unit_id'] = 'RUF531A'
card, errors = card.save()
assert len(errors) == 0
示例3: test_previous_version_id
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_previous_version_id(db_conn, cards_table):
"""
Expect a card to allow a previous version id.
"""
card, errors = Card.insert({
'language': 'en',
'unit_id': 'RUF531',
'name': 'What is?',
'kind': 'video'
})
assert len(errors) == 0
card['previous_id'] = 'TJKL35'
card, errors = card.save()
assert len(errors) == 0
示例4: test_kind
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_kind(db_conn, cards_table):
"""
Expect a card to have a kind.
"""
card, errors = Card.insert({
'previous_id': 'TJKL35',
'language': 'en',
'unit_id': 'RUF531',
'name': 'What is?',
})
assert len(errors) == 1
card['kind'] = 'video'
card, errors = card.save()
assert len(errors) == 0
示例5: create_entity
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def create_entity(data):
"""
Given a kind and some json, call insert on that kind
and return the results.
"""
if 'card' in data:
return Card.insert(data['card'])
# TODO-1 This needs to also get the right card kind...
elif 'unit' in data:
return Unit.insert(data['unit'])
elif 'set' in data:
return Set.insert(data['set'])
return None, []
示例6: test_tags
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_tags(db_conn, cards_table):
"""
Expect a card to allow tags.
"""
card, errors = Card.insert({
'previous_id': 'TJKL35',
'language': 'en',
'unit_id': 'RUF531',
'name': 'What is?',
'kind': 'video'
})
assert len(errors) == 0
card['tags'] = ['B', 'A']
card, errors = card.save()
assert len(errors) == 0
示例7: test_status
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import insert [as 别名]
def test_status(db_conn, cards_table):
"""
Expect a card version status to be a string.
"""
card, errors = Card.insert({
'previous_id': 'TJKL35',
'language': 'en',
'unit_id': 'RUF531',
'name': 'What is?',
'kind': 'video'
})
assert len(errors) == 0
assert card['status'] == 'pending'
card['status'] = 'accepted'
card, errors = card.save()
assert len(errors) == 0