def add(user): """Interface for adding builds Checks if required parameters are present before proceeding Returns: Json formatted message with request status """ config = request.get_json() if not config.keys() >= { 'repo_name', 'repo_provider', }: return jsonify({'message': 'Invalid request'}), 401 repo_branch = config.get('repo_branch', 'master') gitlab_addr = config.get('gitlab_addr', None) url = provider(config['repo_provider'], config['repo_name'], user.username, repo_branch, gitlab_addr) return jsonify({'message': 'Build added successfully'})
def test_github_url(self): rv = git.provider('github', 'test', 'root') url = 'https://raw.githubusercontent.com/test/root/master/.octoci.yml' assert rv == url
def test_invalid_parameter(self): rv = git.provider('', 'test', 'root', 'https://localhost') assert rv == 'Invalid parameters'
def test_invalid_gitlab_url(self): rv = git.provider('gitlab', 'test', 'root') assert rv == 'Gitlab url missing'
def test_gitlab_url(self): rv = git.provider('gitlab', 'test', 'root', 'https://localhost') url = 'https://localhost/root/test/raw/master/.octoci.yml' assert rv == url