예제 #1
0
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
0
def test_entity_id(db_conn, cards_table):
    """
    Expect a card to require an entity_id.
    """

    card, errors = Card.insert(db_conn, {
        'previous_id': 'TJKL35',
        'language': 'en',
        'unit_id': 'RUF531',
        'name': 'What is?',
        'kind': 'video'
    })
    assert len(errors) == 0
    assert card['entity_id']
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
파일: entity.py 프로젝트: Folashade/sagefy
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, []
예제 #7
0
파일: entity.py 프로젝트: Folashade/sagefy
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, []
예제 #8
0
def test_entity_id(db_conn, cards_table):
    """
    Expect a card to require an entity_id.
    """

    card, errors = Card.insert(
        db_conn, {
            'previous_id': 'TJKL35',
            'language': 'en',
            'unit_id': 'RUF531',
            'name': 'What is?',
            'kind': 'video'
        })
    assert len(errors) == 0
    assert card['entity_id']
예제 #9
0
def test_name(db_conn, cards_table):
    """
    Expect a card to require a name.
    """

    card, errors = Card.insert(db_conn, {
        'previous_id': 'TJKL35',
        'language': 'en',
        'unit_id': 'RUF531',
        'kind': 'video'
    })
    assert len(errors) == 1
    card['name'] = 'What is?'
    card, errors = card.save(db_conn)
    assert len(errors) == 0
예제 #10
0
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
예제 #11
0
def test_name(db_conn, cards_table):
    """
    Expect a card to require a name.
    """

    card, errors = Card.insert(
        db_conn, {
            'previous_id': 'TJKL35',
            'language': 'en',
            'unit_id': 'RUF531',
            'kind': 'video'
        })
    assert len(errors) == 1
    card['name'] = 'What is?'
    card, errors = card.save(db_conn)
    assert len(errors) == 0
예제 #12
0
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