示例#1
0
def oldest(owner=None, repo=None, id=False, branch=False):
    old_pull_request = None
    path = "{0}repositories/{1}/{2}/pullrequests/".format(BASE_URL_V2, owner, repo)
    res = requests.get(path, auth=(USERNAME, PASSWORD))

    if res.content:
        pulls = json.loads(res.content).get('values')
        old_pull_request = Pull.oldest(pulls)
    if id:
        result =  old_pull_request.get('id')
        puts(str(result))
        return 1
    if branch:
        result =  old_pull_request.get('branch')
        puts(str(result))
        return 1
    else:
        puts(colored.magenta(columns(['Id', 5], ['Branch', 55])))
        puts(colored.green(columns([str(old_pull_request['id']), 5], [old_pull_request['branch'], 55])))
        return 0
示例#2
0
def oldest(owner=None, repo=None, id=False, branch=False):
    old_pull_request = None
    path = "{0}repositories/{1}/{2}/pullrequests/".format(
        BASE_URL_V2, owner, repo)
    res = requests.get(path, auth=(USERNAME, PASSWORD))

    if res.content:
        pulls = json.loads(res.content).get('values')
        old_pull_request = Pull.oldest(pulls)
    if id:
        result = old_pull_request.get('id')
        puts(str(result))
        return 1
    if branch:
        result = old_pull_request.get('branch')
        puts(str(result))
        return 1
    else:
        puts(colored.magenta(columns(['Id', 5], ['Branch', 55])))
        puts(
            colored.green(
                columns([str(old_pull_request['id']), 5],
                        [old_pull_request['branch'], 55])))
        return 0
示例#3
0
    def test_get_when_empty(self):
        expected = {}
        result = Pull.oldest({})

        self.assertEquals(expected, result)
示例#4
0
    def test_get_when_have_one(self):
        expected = {'branch': 'develop', 'id': 85}
        result = Pull.oldest(self.obj)

        self.assertEquals(expected, result)
示例#5
0
    def test_get_more_old_correct(self):

        expected = {'branch': 'develop', 'id': 85}
        result = Pull.oldest(self.obj)

        self.assertEquals(expected, result)
示例#6
0
    def test_get_when_empty(self):
        expected = {}
        result = Pull.oldest({})

        self.assertEquals(expected, result)
示例#7
0
    def test_get_when_have_one(self):
        expected = {'branch': 'develop', 'id': 85}
        result = Pull.oldest(self.obj)

        self.assertEquals(expected, result)
示例#8
0
    def test_get_more_old_correct(self):

        expected = {'branch': 'develop', 'id': 85}
        result = Pull.oldest(self.obj)

        self.assertEquals(expected, result)