當前位置: 首頁>>代碼示例>>Python>>正文


Python Card.insert方法代碼示例

本文整理匯總了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'
開發者ID:Folashade,項目名稱:sagefy,代碼行數:15,代碼來源:test_models_card.py

示例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
開發者ID:Folashade,項目名稱:sagefy,代碼行數:17,代碼來源:test_models_card.py

示例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
開發者ID:Folashade,項目名稱:sagefy,代碼行數:17,代碼來源:test_models_card.py

示例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
開發者ID:Folashade,項目名稱:sagefy,代碼行數:17,代碼來源:test_models_card.py

示例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, []
開發者ID:Folashade,項目名稱:sagefy,代碼行數:17,代碼來源:entity.py

示例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
開發者ID:Folashade,項目名稱:sagefy,代碼行數:18,代碼來源:test_models_card.py

示例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
開發者ID:Folashade,項目名稱:sagefy,代碼行數:19,代碼來源:test_models_card.py


注:本文中的models.card.Card.insert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。