Example #1
0
def minimal_request_rm(db):
    """
    Create and return an instance of the RequestRm class.

    The request instance will have the minimal set of required attributes set,
    and it'll be committed to the database.

    :param flask_sqlalchemy.SQLAlchemy db: the connection to the database
    :return: the newly created request object
    :rtype: RequestRm
    """
    binary_image = models.Image(
        pull_specification='quay.io/rm/binary-image:latest')
    db.session.add(binary_image)
    from_index_image = models.Image(
        pull_specification='quay.io/rm/index-image:latest')
    db.session.add(from_index_image)
    operator = models.Operator(name='operator')
    db.session.add(operator)
    batch = models.Batch()
    db.session.add(batch)
    request = models.RequestRm(batch=batch,
                               binary_image=binary_image,
                               from_index=from_index_image,
                               operators=[operator])
    db.session.add(request)
    db.session.commit()
    return request
Example #2
0
def test_batch_request_states(db):
    binary_image = models.Image(pull_specification='quay.io/add/binary-image:latest')
    db.session.add(binary_image)
    batch = models.Batch()
    db.session.add(batch)
    for state in ('in_progress', 'failed', 'complete'):
        request = models.RequestAdd(batch=batch, binary_image=binary_image)
        request.add_state(state, 'Some state')
        db.session.add(request)

    db.session.commit()

    assert request.batch.request_states == ['in_progress', 'failed', 'complete']
Example #3
0
def test_batch_state(last_request_state, db):
    binary_image = models.Image(pull_specification='quay.io/add/binary-image:latest')
    db.session.add(binary_image)
    batch = models.Batch()
    db.session.add(batch)
    for i in range(3):
        request = models.RequestAdd(batch=batch, binary_image=binary_image)
        request.add_state('complete', 'Some reason')
        db.session.add(request)

    request = models.RequestAdd(batch=batch, binary_image=binary_image)
    request.add_state(last_request_state, 'Some reason')
    db.session.add(request)
    db.session.commit()

    assert request.batch.state == last_request_state
Example #4
0
def test_request_add_tag(db, minimal_request):
    binary_image = models.Image(
        pull_specification='quay.io/add/binary-image:latest2')
    db.session.add(binary_image)
    batch = models.Batch()
    db.session.add(batch)
    request = models.RequestAdd(batch=batch, binary_image=binary_image)
    db.session.add(request)
    db.session.commit()
    minimal_request.add_build_tag('build-tag1')

    minimal_request.add_build_tag('build-tag1')
    minimal_request.add_build_tag('build-tag1')
    minimal_request.add_build_tag('build-tag2')
    db.session.commit()
    assert len(minimal_request.build_tags) == 2
    assert minimal_request.build_tags[0].name == 'build-tag1'
    assert minimal_request.build_tags[1].name == 'build-tag2'
Example #5
0
def minimal_request_add(db):
    """
    Create and return an instance of the RequestAdd class.

    The request instance will have the minimal set of required attributes set,
    and it'll be committed to the database.

    :param flask_sqlalchemy.SQLAlchemy db: the connection to the database
    :return: the newly created request object
    :rtype: RequestAdd
    """
    binary_image = models.Image(
        pull_specification='quay.io/add/binary-image:latest')
    db.session.add(binary_image)
    batch = models.Batch()
    db.session.add(batch)
    request = models.RequestAdd(batch=batch, binary_image=binary_image)
    db.session.add(request)
    db.session.commit()
    return request
Example #6
0
def minimal_request_regenerate_bundle(db):
    """
    Create and return an instance of the RequestRegenerateBundle class.

    The request instance will have the minimal set of required attributes set,
    and it'll be committed to the database.

    :param flask_sqlalchemy.SQLAlchemy db: the connection to the database
    :return: the newly created request object
    :rtype: RequestRegenerateBundle
    """
    from_bundle_image = models.Image(
        pull_specification='quay.io/regen-bundle/bundle-image:latest')
    db.session.add(from_bundle_image)
    batch = models.Batch()
    db.session.add(batch)
    request = models.RequestRegenerateBundle(
        batch=batch, from_bundle_image=from_bundle_image)
    db.session.add(request)
    db.session.commit()
    return request