Beispiel #1
0
def test_body(db_conn, sets_table, units_table):
    """
    Expect a set to require a body.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(db_conn, {"name": "Statistics", "members": [{"id": "A", "kind": "unit"}]})
    assert len(errors) == 1
    set_["body"] = "A beginning course focused on probability."
    set_, errors = set_.save(db_conn)
    assert len(errors) == 0
Beispiel #2
0
def test_members(db_conn, sets_table, units_table):
    """
    Expect a set to record a list of members.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(db_conn, {"name": "Statistics", "body": "A beginning course focused on probability."})
    assert len(errors) == 1
    set_["members"] = [{"id": "A", "kind": "unit"}]
    set_, errors = set_.save(db_conn)
    assert len(errors) == 0
Beispiel #3
0
def test_entity(db_conn, sets_table):
    """
    Expect a set to require an entity_id.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }]
    })
    assert len(errors) == 0
    assert set_['entity_id']
Beispiel #4
0
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, []
Beispiel #5
0
def test_previous(db_conn, sets_table):
    """
    Expect a set to allow a previous version id.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
        'previous_id': 'fdsjKO',
    })
    assert len(errors) == 0
Beispiel #6
0
def test_tags(db_conn, sets_table):
    """
    Expect a set to allow tags.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
        'tags': ['A', 'B', 'C']
    })
    assert len(errors) == 0
Beispiel #7
0
def test_tags(db_conn, sets_table):
    """
    Expect a set to allow tags.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
        'tags': ['A', 'B', 'C']
    })
    assert len(errors) == 0
Beispiel #8
0
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, []
Beispiel #9
0
def test_entity(db_conn, sets_table):
    """
    Expect a set to require an entity_id.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }]
    })
    assert len(errors) == 0
    assert set_['entity_id']
Beispiel #10
0
def test_previous(db_conn, sets_table):
    """
    Expect a set to allow a previous version id.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
        'previous_id': 'fdsjKO',
    })
    assert len(errors) == 0
Beispiel #11
0
def test_members(db_conn, sets_table):
    """
    Expect a set to record a list of members.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
    })
    assert len(errors) == 1
    set_['members'] = [{
        'id': 'A',
        'kind': 'unit',
    }]
    set_, errors = set_.save()
    assert len(errors) == 0
Beispiel #12
0
def test_language(db_conn, sets_table, units_table):
    """
    Expect a set to require a language.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(db_conn, {
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 0
    assert set_['language'] == 'en'
Beispiel #13
0
def test_previous(db_conn, sets_table, units_table):
    """
    Expect a set to allow a previous version id.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(
        db_conn,
        {
            "name": "Statistics",
            "body": "A beginning course focused on probability.",
            "members": [{"id": "A", "kind": "unit"}],
            "previous_id": "fdsjKO",
        },
    )
    assert len(errors) == 0
Beispiel #14
0
def test_body(db_conn, sets_table):
    """
    Expect a set to require a body.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 1
    set_['body'] = 'A beginning course focused on probability.'
    set_, errors = set_.save()
    assert len(errors) == 0
Beispiel #15
0
def test_tags(db_conn, sets_table, units_table):
    """
    Expect a set to allow tags.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(
        db_conn,
        {
            "name": "Statistics",
            "body": "A beginning course focused on probability.",
            "members": [{"id": "A", "kind": "unit"}],
            "tags": ["A", "B", "C"],
        },
    )
    assert len(errors) == 0
Beispiel #16
0
def test_body(db_conn, sets_table):
    """
    Expect a set to require a body.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 1
    set_['body'] = 'A beginning course focused on probability.'
    set_, errors = set_.save()
    assert len(errors) == 0
Beispiel #17
0
def test_language(db_conn, sets_table, units_table):
    """
    Expect a set to require a language.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(
        db_conn,
        {
            "name": "Statistics",
            "body": "A beginning course focused on probability.",
            "members": [{"id": "A", "kind": "unit"}],
        },
    )
    assert len(errors) == 0
    assert set_["language"] == "en"
Beispiel #18
0
def test_name(db_conn, sets_table, units_table):
    """
    Expect a set to require a name.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(db_conn, {
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 1
    set_['name'] = 'Statistics'
    set_, errors = set_.save(db_conn)
    assert len(errors) == 0
Beispiel #19
0
def test_members(db_conn, sets_table, units_table):
    """
    Expect a set to record a list of members.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(db_conn, {
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
    })
    assert len(errors) == 1
    set_['members'] = [{
        'id': 'A',
        'kind': 'unit',
    }]
    set_, errors = set_.save(db_conn)
    assert len(errors) == 0
Beispiel #20
0
def test_status(db_conn, sets_table):
    """
    Expect a set status to be a string.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 0
    assert set_['status'] == 'pending'
    set_['status'] = 'accepted'
    set_, errors = set_.save()
    assert len(errors) == 0
Beispiel #21
0
def test_status(db_conn, sets_table):
    """
    Expect a set status to be a string.
    """

    set_, errors = Set.insert({
        'name': 'Statistics',
        'body': 'A beginning course focused on probability.',
        'members': [{
            'id': 'A',
            'kind': 'unit',
        }],
    })
    assert len(errors) == 0
    assert set_['status'] == 'pending'
    set_['status'] = 'accepted'
    set_, errors = set_.save()
    assert len(errors) == 0
Beispiel #22
0
def test_status(db_conn, sets_table, units_table):
    """
    Expect a set status to be a string.
    """

    create_unit_a(db_conn, units_table)
    set_, errors = Set.insert(
        db_conn,
        {
            "name": "Statistics",
            "body": "A beginning course focused on probability.",
            "members": [{"id": "A", "kind": "unit"}],
        },
    )
    assert len(errors) == 0
    assert set_["status"] == "pending"
    set_["status"] = "accepted"
    set_, errors = set_.save(db_conn)
    assert len(errors) == 0