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
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
def test_get_when_empty(self): expected = {} result = Pull.oldest({}) self.assertEquals(expected, result)
def test_get_when_have_one(self): expected = {'branch': 'develop', 'id': 85} result = Pull.oldest(self.obj) self.assertEquals(expected, result)
def test_get_more_old_correct(self): expected = {'branch': 'develop', 'id': 85} result = Pull.oldest(self.obj) self.assertEquals(expected, result)