def test_get_issue(self): num_1 = mock.create_issue(org, repo, username, token, 'A', 'ala') num_2 = mock.create_issue(org, repo, username, token, 'B', 'balala') issue1 = mock.get_issue(org, repo, username, token, num_1) self.assertEqual(issue1['title'], 'A') self.assertEqual(issue1['body'], 'ala') self.assertEqual(issue1['user'], '') self.assertEqual(issue1['state'], 'open') self.assertEqual(issue1['number'], num_1)
def test_close_issue(self): num = mock.create_issue(org, repo, username, token, 'A', 'ala') issue1 = mock.get_issue(org, repo, username, token, num) issues = mock.get_issues(org, repo, username, token) mock.close_issue(org, repo, username, token, num) issue1_closed = mock.get_issue(org, repo, username, token, num) issue1['state'] = 'closed' self.assertEqual(issue1_closed, issue1)
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'])
def _menu_new_issue(settings): title = input('Enter title: ') body = input('Enter body: ') label = input('Enter labels (comma separated): ') labels = label.split(',') return api.create_issue( org=settings['org'], repo=settings['repo'], username=settings['user'], token=settings['token'], title=title, body=body)
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"] new_issues = yaml.load(open("issues.yml")) for issue in new_issues: title = issue["title"] body = issue["body"] api.create_issue(org, repo, user, token, title, body) print("Created issue: " + title)
org = 'pgdr' username = '******' token = 'none' repo = 'githubapimock' 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,
def test_get_issues(self): num = mock.create_issue(org, repo, username, token, 'A', 'ala') issue1 = mock.get_issue(org, repo, username, token, num) issues = mock.get_issues(org, repo, username, token) self.assertIn(issue1, issues)
def test_create(self): num = mock.create_issue(org, repo, username, token, 'A', 'ala') self.assertTrue(num >= 0) # just testing int
from pprint import pprint import requests import githubapimock username = '******' token = 'none' repo = 'githubapimock' githubapimock.new() # for mocking num_1 = githubapimock.create_issue(repo, username, token, 'Xyz', 'xyz') num_2 = githubapimock.create_issue(repo, username, token, 'Omg', 'omg') issues = githubapimock.get_issues(repo, username, token) pprint(issues) githubapimock.close() # for mocking
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"] username = settings["user"] token = settings["token"] title = "My first client issue from Python" body = "This was created from client application" labels = ['todo', 'help_wanted'] issue_id = api.create_issue(org, repo, username, token, title, body) print("Created issue: " + str(issue_id)) api.set_labels(org, repo, username, token, issue_id, labels) print("Added labels " + str(labels) + " to issue " + str(issue_id))