Example #1
0
    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)
Example #2
0
    def get_pull_request(self):
        fixture = load_fixture('pull_request.json')
        model = PullRequest.from_json(fixture, self.session)

        files = load_fixture('one_file_pull_request.json')
        model.files = lambda: create_pull_files(files)

        return GithubPullRequest(model)
Example #3
0
    def get_pull_request(self):
        fixture = load_fixture('pull_request.json')
        model = PullRequest.from_json(fixture, self.session)

        files = load_fixture('one_file_pull_request.json')
        model.files = lambda: create_pull_files(files)

        return GithubPullRequest(model)
	def _construct_pull_request(self, pull_request_dict):
		pull_request = PullRequest.from_dict(pull_request_dict)
		pull_request.session = self.github.session
		logging.info('Handling PR #{number}: "{title}" ({html_url})'.format(
			number=pull_request.number,
			title=pull_request.title,
			html_url=pull_request.html_url))
		return pull_request
Example #5
0
    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)
Example #6
0
 def _construct_pull_request(self, pull_request_dict):
     pull_request = PullRequest.from_dict(pull_request_dict)
     pull_request.session = self.github.session
     logging.info('Handling PR #{number}: "{title}" ({html_url})'.format(
         number=pull_request.number,
         title=pull_request.title,
         html_url=pull_request.html_url))
     return pull_request
Example #7
0
    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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    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)
Example #11
0
    def get_pull_request(self):
        fixture = load_fixture('pull_request.json')
        model = PullRequest.from_json(fixture, self.session)

        # TODO This needs to be adapted for local diffs
        # Perhaps pull.read_diff can be added and mocked
        # here?
        files = load_fixture('one_file_pull_request.json')
        model.files = lambda: create_pull_files(files)

        return GithubPullRequest(model)
Example #12
0
    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)
Example #13
0
    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)
Example #14
0
 def setUp(self):
     fixture = load_fixture('pull_request.json')
     self.session = GitHubSession()
     self.model = PullRequest.from_json(fixture, self.session)
Example #15
0
 def setUp(self):
     fixture = load_fixture('pull_request.json')
     self.model = PullRequest(json.loads(fixture)['pull_request'])
Example #16
0
def _pullreqev(payload):
    from github3.pulls import PullRequest
    if payload.get('pull_request'):
        payload['pull_request'] = PullRequest(payload['pull_request'], None)
    return payload
Example #17
0
 def setUp(self):
     fixture = load_fixture('pull_request.json')
     self.session = GitHubSession()
     self.model = PullRequest.from_json(fixture, self.session)