Ejemplo n.º 1
0
def test_get_records_by_parent(app, db, location):
    """Test get by parent."""
    # Create two published records
    record_v1 = Record.publish(Draft.create({}))
    db.session.commit()
    draft = Draft.new_version(record_v1)
    draft.commit()
    db.session.commit()
    record_v2 = Record.publish(draft)
    db.session.commit()

    # Get all two versions.
    parent = record_v2.parent
    records = Record.get_records_by_parent(parent)

    # Check that we reuse the parent we passed in.
    assert id(parent) == id(records[0].parent) == id(records[1].parent)
Ejemplo n.º 2
0
def test_draft_create_new_version(app, db, location):
    """Test draft creation of the parent record."""
    # A published record.
    record = Record.publish(Draft.create({}))
    db.session.commit()
    # Create a draft for a new version (happens in service.new_version())
    draft = Draft.new_version(record)
    draft.commit()
    db.session.commit()

    record = Record.get_record(record.id)
    draft = Draft.get_record(draft.id)

    assert record.id != draft.id  # different uuids
    assert record.parent.id == draft.parent.id  # same parent
    assert draft.versions.is_latest_draft is True
    assert draft.versions.is_latest is False
    assert record.versions.is_latest_draft is False
    assert record.versions.is_latest is True