Exemple #1
0
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'})
Exemple #2
0
    def test_github_url(self):
        rv = git.provider('github', 'test', 'root')
        url = 'https://raw.githubusercontent.com/test/root/master/.octoci.yml'

        assert rv == url
Exemple #3
0
    def test_invalid_parameter(self):
        rv = git.provider('', 'test', 'root', 'https://localhost')

        assert rv == 'Invalid parameters'
Exemple #4
0
    def test_invalid_gitlab_url(self):
        rv = git.provider('gitlab', 'test', 'root')

        assert rv == 'Gitlab url missing'
Exemple #5
0
    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