Exemplo n.º 1
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env python
import commons

builds_helper = commons.get_build_helper()
deploys_helper = commons.get_deploy_helper()


def pick_build_id(buildName, x):
    builds = builds_helper.get_builds(commons.REQUEST,
                                      name=buildName,
                                      pageIndex=1,
                                      pageSize=x)
    return builds[x - 1]['id']


def create(name, stage, x):
    buildName = "sample-service-{}".format(x)
    buildId = pick_build_id(buildName, 0)
    id = deploys_helper.deploy(commons.REQUEST, name, stage, buildId)['id']
Exemplo n.º 2
0
#  
#     http://www.apache.org/licenses/LICENSE-2.0
#    
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -*- coding: utf-8 -*-

import unittest
import time
import commons

builds_helper = commons.get_build_helper()


class TestBuilds(unittest.TestCase):
    def test_build_apis(self):
        request1 = self._generate_request("build1", "commit-1")
        request2 = self._generate_request("build2", "commit-1")
        request3 = self._generate_request("build2", "commit-2", "branch-1")
        id1 = builds_helper.publish_build(commons.REQUEST, request1)['id']
        id2 = builds_helper.publish_build(commons.REQUEST, request2)['id']
        id3 = builds_helper.publish_build(commons.REQUEST, request3)['id']

        build1 = builds_helper.get_build(commons.REQUEST, id1)
        builds = builds_helper.get_builds(commons.REQUEST, name="build1", branch="master",
                                          pageIndex=1, pageSize=1)
        build2 = builds[0]