def test_labels_in_issues(self): num = mock.create_issue(org, repo, username, token, 'A', 'ala') lab_exp = ['lab1', 'lab2'] mock.set_labels(org, repo, username, token, num, lab_exp) issue = mock.get_issue(org, repo, username, token, num) lab_act = [label['name'] for label in issue['labels']] self.assertEqual(lab_exp, lab_act)
def test_label_issue(self): num = mock.create_issue(org, repo, username, token, 'A', 'ala') lab_exp = ['lab1', 'lab2'] mock.set_labels(org, repo, username, token, num, lab_exp) lab_act = mock.get_labels(org, repo, username, token, num) self.assertEqual(lab_exp, lab_act) mock.set_labels(org, repo, username, token, num, ['only']) only = mock.get_labels(org, repo, username, token, num) self.assertEqual(only, ['only'])
if os.getenv('MOCK'): api.new() # for mocking issues = yaml.load(open('issues.yml')) nums = [] for issue in issues: num = api.create_issue(org=org, repo=repo, username=username, token=token, title=issue['title'], body=issue['body']) nums.append(num) api.set_labels(org=org, repo=repo, username=username, token=token, issue_id=nums[0], labels=['in progress', 'good first issue', 'help wanted']) for num in nums[1:]: api.set_labels(org=org, repo=repo, username=username, token=token, issue_id=num, labels=['todo', 'enhancement'])
import os import yaml import githubapimock as api config_path = os.path.expanduser("~/repo.yml") settings = yaml.load(open(config_path)) org = settings["org"] repo = settings["repo"] user = settings["user"] token = settings["token"] title = "" while title != "q": title = input("Title: ") body = input("Body: ") label = input("Label: ") labels = [label] issue_id = api.create_issue(org, repo, user, token, title, body) print("Created issue: "+ str(issue_id) + " in " + org + "/" + repo) api.set_labels(org, user, token, issue_id, label) print("Added labels: " + str(labels) + " to issues " + str(issue_id))
config_path = os.path.expanduser("~/repo.yml") settings = yaml.load(open(config_path)) user = settings["user"] org = settings["org"] repo = settings["repo"] token = settings["token"] """ title = "My first client issue" body = "This was created from the client" labels = ['todo', 'helpwanted', 'autogenerated'] issue_id = api.create_issue(org, repo, user, token, title, body) print ( "Created issue: " + str (issue_id )) api.set_labels(org, repo, user, token, issue_id, labels) print ("Added labels " + str(labels) + " to issue " + str(issue_id )) """ title = "" while title != "q": title = input("Title: ") body = input("Body: ") label = input("Label: ") labels = [label] issue_id = api.create_issue(org, repo, user, token, title, body) print("Created issue: " + str(issue_id) + " in " + org + "/" + repo) api.set_labels(org, repo, user, token, issue_id, labels) print("Added labels " + str(labels) + " to issue " + str(issue_id))