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
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
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']
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, []
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
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
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
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, []
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']
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
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
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'
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
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
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
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
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"
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
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
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
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
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