Fix API tests
This commit is contained in:
parent
d5c70878c5
commit
5a8093bbea
1 changed files with 38 additions and 23 deletions
|
@ -7,8 +7,9 @@ from urllib import urlencode
|
||||||
from urlparse import urlparse, urlunparse, parse_qs
|
from urlparse import urlparse, urlunparse, parse_qs
|
||||||
|
|
||||||
from endpoints.api import api_bp, api
|
from endpoints.api import api_bp, api
|
||||||
|
from endpoints.building import PreparedBuild
|
||||||
from endpoints.webhooks import webhooks
|
from endpoints.webhooks import webhooks
|
||||||
from endpoints.trigger import BuildTrigger as BuildTriggerBase
|
from endpoints.trigger import BuildTriggerHandler
|
||||||
from app import app
|
from app import app
|
||||||
from initdb import setup_database_for_testing, finished_database_for_testing
|
from initdb import setup_database_for_testing, finished_database_for_testing
|
||||||
from data import model, database
|
from data import model, database
|
||||||
|
@ -2425,44 +2426,58 @@ class TestOrganizationApplicationResetClientSecret(ApiTestCase):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FakeBuildTrigger(BuildTriggerBase):
|
class FakeBuildTrigger(BuildTriggerHandler):
|
||||||
@classmethod
|
@classmethod
|
||||||
def service_name(cls):
|
def service_name(cls):
|
||||||
return 'fakeservice'
|
return 'fakeservice'
|
||||||
|
|
||||||
def list_build_sources(self, auth_token):
|
def list_build_sources(self):
|
||||||
return [{'first': 'source'}, {'second': auth_token}]
|
return [{'first': 'source'}, {'second': self.auth_token}]
|
||||||
|
|
||||||
def list_build_subdirs(self, auth_token, config):
|
def list_build_subdirs(self):
|
||||||
return [auth_token, 'foo', 'bar', config['somevalue']]
|
return [self.auth_token, 'foo', 'bar', self.config['somevalue']]
|
||||||
|
|
||||||
def handle_trigger_request(self, request, auth_token, config):
|
def handle_trigger_request(self, request):
|
||||||
return ('foo', ['bar'], 'build-name', 'subdir', {'foo': 'bar'})
|
prepared = PreparedBuild(self.trigger)
|
||||||
|
prepared.build_name = 'build-name'
|
||||||
|
prepared.tags = ['bar']
|
||||||
|
prepared.dockerfile_id = 'foo'
|
||||||
|
prepared.subdirectory = 'subdir'
|
||||||
|
prepared.metadata = {'foo': 'bar'}
|
||||||
|
prepared.is_manual = False
|
||||||
|
return prepared
|
||||||
|
|
||||||
def is_active(self, config):
|
def is_active(self):
|
||||||
return 'active' in config and config['active']
|
return 'active' in self.config and self.config['active']
|
||||||
|
|
||||||
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
|
def activate(self, standard_webhook_url):
|
||||||
config['active'] = True
|
self.config['active'] = True
|
||||||
return config, {}
|
return self.config, {}
|
||||||
|
|
||||||
def deactivate(self, auth_token, config):
|
def deactivate(self):
|
||||||
config['active'] = False
|
self.config['active'] = False
|
||||||
return config
|
return self.config
|
||||||
|
|
||||||
def manual_start(self, trigger, run_parameters=None):
|
def manual_start(self, run_parameters=None):
|
||||||
return ('foo', ['bar'], 'build-name', 'subdir', {'foo': 'bar'})
|
prepared = PreparedBuild(self.trigger)
|
||||||
|
prepared.build_name = 'build-name'
|
||||||
|
prepared.tags = ['bar']
|
||||||
|
prepared.dockerfile_id = 'foo'
|
||||||
|
prepared.subdirectory = 'subdir'
|
||||||
|
prepared.metadata = {'foo': 'bar'}
|
||||||
|
prepared.is_manual = True
|
||||||
|
return prepared
|
||||||
|
|
||||||
def dockerfile_url(self, auth_token, config):
|
def dockerfile_url(self):
|
||||||
return 'http://some/url'
|
return 'http://some/url'
|
||||||
|
|
||||||
def load_dockerfile_contents(self, auth_token, config):
|
def load_dockerfile_contents(self):
|
||||||
if not 'dockerfile' in config:
|
if not 'dockerfile' in self.config:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return config['dockerfile']
|
return self.config['dockerfile']
|
||||||
|
|
||||||
def list_field_values(self, auth_token, config, field_name):
|
def list_field_values(self, field_name):
|
||||||
if field_name == 'test_field':
|
if field_name == 'test_field':
|
||||||
return [1, 2, 3]
|
return [1, 2, 3]
|
||||||
|
|
||||||
|
|
Reference in a new issue