def get_pull_request(self): fixture = load_fixture('pull_request.json') model = PullRequest(json.loads(fixture)['pull_request']) files = load_fixture('one_file_pull_request.json') model.files = lambda: create_pull_files(files) return GithubPullRequest(model)
def test_clone_url__private_fork__not_a_fork(self): fixture = load_fixture('pull_request.json') data = json.loads(fixture)['pull_request'] pull = GithubPullRequest(PullRequest(data)) eq_(False, pull.from_private_fork) eq_(data['head']['repo']['clone_url'], pull.clone_url) eq_('test', pull.head_branch)
def test_maintainer_can_modify__forked_repo(self): fixture = load_fixture('pull_request.json') data = json.loads(fixture)['pull_request'] # Make repo different data['head']['repo']['full_name'] = 'contributor/lint-test' pull = GithubPullRequest(PullRequest(data)) eq_(True, pull.maintainer_can_modify, 'reflects flag') # Different repo reflects flag data data['maintainer_can_modify'] = False pull = GithubPullRequest(PullRequest(data)) eq_(False, pull.maintainer_can_modify) data['maintainer_can_modify'] = True pull = GithubPullRequest(PullRequest(data)) eq_(True, pull.maintainer_can_modify)
def test_clone_url__private_fork__not_a_fork(self): fixture = load_fixture('pull_request.json') data = json.loads(fixture) pull = GithubPullRequest(PullRequest(data, self.session)) self.assertEqual(False, pull.from_private_fork) self.assertEqual(data['head']['repo']['clone_url'], pull.clone_url) self.assertEqual('test', pull.head_branch)
def test_clone_url__private_fork__forked(self): fixture = load_fixture('pull_request.json') data = json.loads(fixture)['pull_request'] data['head']['repo']['full_name'] = 'contributor/lint-test' data['head']['repo']['fork'] = True pull = GithubPullRequest(PullRequest(data)) eq_(False, pull.from_private_fork)
def test_maintainer_can_modify__same_repo(self): pull = GithubPullRequest(self.model) eq_(True, pull.maintainer_can_modify) fixture = load_fixture('pull_request.json') data = json.loads(fixture)['pull_request'] data['maintainer_can_modify'] = False model = PullRequest(data) pull = GithubPullRequest(model) eq_(True, pull.maintainer_can_modify)
def test_maintainer_can_modify__same_repo(self): pull = GithubPullRequest(self.model) self.assertEqual(True, pull.maintainer_can_modify) fixture = load_fixture('pull_request.json') data = json.loads(fixture) data['maintainer_can_modify'] = False model = PullRequest(data, self.session) pull = GithubPullRequest(model) self.assertEqual(True, pull.maintainer_can_modify)
def test_clone_url__private_fork(self): fixture = load_fixture('pull_request.json') data = json.loads(fixture)['pull_request'] data['head']['repo']['full_name'] = 'contributor/lint-test' data['head']['repo']['clone_url'] = 'secret-repo' data['head']['repo']['fork'] = True data['head']['repo']['private'] = True pull = GithubPullRequest(PullRequest(data)) eq_(True, pull.from_private_fork) eq_(data['base']['repo']['clone_url'], pull.clone_url) eq_('refs/pull/1/head', pull.head_branch)
def _pullreqev(payload): from github3.pulls import PullRequest if payload.get('pull_request'): payload['pull_request'] = PullRequest(payload['pull_request'], None) return payload
def setUp(self): fixture = load_fixture('pull_request.json') self.model = PullRequest(json.loads(fixture)['pull_request'])