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
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']
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'
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