def test_pull_request(self): model = self.repo_model model.pull_request = Mock(return_value=sentinel.pull_request) repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model pull = repo.pull_request(1) ok_(isinstance(pull, GithubPullRequest), 'Should be wrapped object')
def test_repository(self, github_mock): github_mock.get_repository.return_value = self.repo_model repo = GithubRepository(config, 'markstory', 'lint-test') eq_(self.repo_model, repo.repository()) github_mock.get_repository.assert_called_with(config, 'markstory', 'lint-test')
def test_pull_request(self): model = self.repo_model model.pull_request = Mock(return_value=sentinel.pull_request) repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model pull = repo.pull_request(1) ok_(isinstance(pull, GithubPullRequest), 'Should be wrapped object')
def test_create_status(self): model = self.repo_model model.create_status = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.create_status('abc123', 'succeeded', 'all good') model.create_status.assert_called_with('abc123', 'succeeded', None, 'all good', 'lintreview')
def test_ensure_label__exists(self): model = self.repo_model model.create_label = Mock() model.label = Mock(return_value=True) repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.ensure_label('A label') eq_(False, model.create_label.called)
def test_ensure_label__missing(self): model = self.repo_model model.label = Mock(return_value=None) model.create_label = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.ensure_label('A label') model.create_label.assert_called_with(name='A label', color='bfe5bf')
def test_ensure_label__exists(self): model = self.repo_model model.create_label = Mock() model.label = Mock(return_value=True) repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.ensure_label('A label') eq_(False, model.create_label.called)
def test_repository(self, github_mock): github_mock.get_repository.return_value = self.repo_model repo = GithubRepository(config, 'markstory', 'lint-test') eq_(self.repo_model, repo.repository()) github_mock.get_repository.assert_called_with( config, 'markstory', 'lint-test')
def test_ensure_label__missing(self): model = self.repo_model model.label = Mock(return_value=None) model.create_label = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.ensure_label('A label') model.create_label.assert_called_with( name='A label', color='bfe5bf')
def test_create_status(self): model = self.repo_model model.create_status = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: self.repo_model repo.create_status('abc123', 'succeeded', 'all good') model.create_status.assert_called_with( 'abc123', 'succeeded', None, 'all good', 'lintreview')
def test_update_checkrun(self): model = self.repo_model model._patch = Mock() model._json = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: model review = { 'conclusion': 'success', 'output': { 'title': 'No lint errors found', 'summary': '', 'annotations': [], } } repo.update_checkrun(99, review) model._patch.assert_called_with( 'https://api.github.com/repos/markstory/lint-test/check-runs/99', data=json.dumps(review), headers={'Accept': 'application/vnd.github.antiope-preview+json'}) assert model._json.called
def test_update_checkrun(self): model = self.repo_model model._patch = Mock() model._json = Mock() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: model review = { 'conclusion': 'success', 'output': { 'title': 'No lint errors found', 'summary': '', 'annotations': [], } } repo.update_checkrun(99, review) model._patch.assert_called_with( 'https://api.github.com/repos/markstory/lint-test/check-runs/99', data=json.dumps(review), headers={'Accept': 'application/vnd.github.antiope-preview+json'}) assert model._json.called
def test_create_checkrun(self): model = self.repo_model post_mock = Mock() json_mock = Mock() model._post = post_mock model._json = json_mock repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: model review = { 'commit_sha': 'abc123', 'conclusion': 'success', 'output': { 'title': 'No lint errors', 'summary': '', 'annotations': [], } } repo.create_checkrun(review) post_mock.assert_called_with( 'https://api.github.com/repos/markstory/lint-test/check-runs', data=review, headers={'Accept': 'application/vnd.github.antiope-preview+json'}) json_mock.assert_called()
def test_create_checkrun(self): model = self.repo_model model._post = Mock() model._json = Mock() import pdb pdb.set_trace() repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: model review = { 'commit_sha': 'abc123', 'conclusion': 'success', 'output': { 'title': 'Style Review', 'summary': '', 'annotations': [], } } repo.create_checkrun(review) model._post.assert_called_with( 'https://api.github.com/repos/markstory/lint-test/check-runs', data=review, headers={'Accept': 'application/vnd.github.antiope-preview+json'}) assert model._json.called
def test_create_checkrun(self): model = self.repo_model post_mock = Mock() json_mock = Mock() model._post = post_mock model._json = json_mock repo = GithubRepository(config, 'markstory', 'lint-test') repo.repository = lambda: model review = { 'commit_sha': 'abc123', 'conclusion': 'success', 'output': { 'title': 'No lint errors', 'summary': '', 'annotations': [], } } repo.create_checkrun(review) post_mock.assert_called_with( 'https://api.github.com/repos/markstory/lint-test/check-runs', data=review, headers={'Accept': 'application/vnd.github.antiope-preview+json'}) json_mock.assert_called()