def test_insert_unit_version(db_conn): create_unit_test_data(db_conn) current_data = get_unit_version(db_conn, unit_version_a_uuid) next_data = { 'user_id': user_a_uuid, 'name': 'test unit add', 'body': 'multiplying numbers is fun', 'require_ids': [uuid.uuid4()] } version, errors = insert_unit_version(db_conn, current_data, next_data) assert errors assert not version current_data['entity_id'] = uuid.uuid4() next_data = { 'user_id': user_a_uuid, 'name': 'test unit add', 'body': 'multiplying numbers is fun' } version, errors = insert_unit_version(db_conn, current_data, next_data) assert errors assert not version current_data['entity_id'] = unit_a_uuid version, errors = insert_unit_version(db_conn, current_data, next_data) assert not errors assert version
def test_ensure_no_cycles(db_conn): create_unit_test_data(db_conn) data = get_unit_version(db_conn, unit_version_a_uuid) data['require_ids'] = [unit_b_uuid] errors = ensure_no_cycles(db_conn, data) assert errors data['require_ids'] = [] errors = ensure_no_cycles(db_conn, data) assert not errors
def test_update_unit(db_conn): create_unit_test_data(db_conn) current_data = get_unit_version(db_conn, unit_version_a_uuid) assert current_data['status'] == 'accepted' unit, errors = update_unit(db_conn, version_id=unit_version_a_uuid, status='pending') assert not errors assert unit['status'] == 'pending'
def test_find_requires_cycle_unit(db_conn): create_unit_test_data(db_conn) data = get_unit_version(db_conn, XU_unit_version_a_uuid) data['require_ids'] = [XU_unit_b_uuid] found = find_requires_cycle(db_conn, 'units', data) assert found data['require_ids'] = [] found = find_requires_cycle(db_conn, 'units', data) assert not found
def get_unit_version_route(request, version_id): """ Get a unit version only knowing the `version_id`. """ db_conn = request['db_conn'] unit_version = get_unit_version(db_conn, version_id) if not unit_version: return abort(404, '7ueX8JHiQ0mMunv3jfKSBg') return 200, {'version': unit_version}
def get_entity_version(db_conn, kind, version_id): """ """ assert kind in ('card', 'unit', 'subject') if kind == 'card': return get_card_version(db_conn, version_id) if kind == 'unit': return get_unit_version(db_conn, version_id) if kind == 'subject': return get_subject_version(db_conn, version_id)
def test_update_entity_statuses(db_conn): create_test_user(db_conn) unit_version_a_uuid = uuid.uuid4() topic_uuid = uuid.uuid4() proposal_uuid = uuid.uuid4() units = [{ 'version_id': unit_version_a_uuid, 'user_id': user_a_uuid, 'entity_id': unit_a_uuid, 'name': 'test unit add', 'body': 'adding numbers is fun', 'status': 'pending', }] raw_insert_units(db_conn, units) topics = [{ 'id': topic_uuid, 'user_id': user_a_uuid, 'entity_id': unit_a_uuid, 'entity_kind': 'unit', 'name': 'Lets talk about adding numbers', }] raw_insert_topics(db_conn, topics) posts = [{ 'id': proposal_uuid, 'kind': 'proposal', 'body': 'A new version', 'entity_versions': [{ 'id': convert_uuid_to_slug(unit_version_a_uuid), 'kind': 'unit', }], 'user_id': user_a_uuid, 'topic_id': topic_uuid, }] raw_insert_posts(db_conn, posts) proposal = get_post(db_conn, {'id': proposal_uuid}) update_entity_statuses(db_conn, proposal) unit = get_unit_version(db_conn, unit_version_a_uuid) assert unit assert unit['status'] == 'accepted'
def test_get_unit_version(db_conn): create_unit_test_data(db_conn) data = get_unit_version(db_conn, unit_version_a_uuid) assert data
def test_deliver_unit(db_conn): create_unit_test_data(db_conn) data = get_unit_version(db_conn, unit_version_a_uuid) assert deliver_unit(data, access=None)