This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/test/test_building.py
Joseph Schorr c35eec0615 Add ability for triggers to be disabled
Will be used in the followup commit to automatically disable broken triggers
2018-03-01 16:49:28 -05:00

43 lines
1.3 KiB
Python

import pytest
from data import model
from endpoints.building import (start_build, PreparedBuild, MaximumBuildsQueuedException,
BuildTriggerDisabledException)
from test.fixtures import *
def test_maximum_builds(app):
# Change the maximum number of builds to 1.
user = model.user.create_user('foobar', 'password', 'foo@example.com')
user.maximum_queued_builds_count = 1
user.save()
repo = model.repository.create_repository('foobar', 'somerepo', user)
# Try to queue a build; should succeed.
prepared_build = PreparedBuild()
prepared_build.build_name = 'foo'
prepared_build.is_manual = True
prepared_build.dockerfile_id = 'foobar'
prepared_build.archive_url = 'someurl'
prepared_build.tags = ['latest']
prepared_build.subdirectory = '/'
prepared_build.context = '/'
prepared_build.metadata = {}
start_build(repo, prepared_build)
# Try to queue a second build; should fail.
with pytest.raises(MaximumBuildsQueuedException):
start_build(repo, prepared_build)
def test_start_build_disabled_trigger(app):
trigger = model.build.list_build_triggers('devtable', 'building')[0]
trigger.enabled = False
trigger.save()
build = PreparedBuild(trigger=trigger)
with pytest.raises(BuildTriggerDisabledException):
start_build(trigger.repository, build)