示例#1
0
    def test_repo_commit_in_last_day_exception(self):

        def se_exc(foo):
            raise GithubException("foo", "bar")

        mock_repo = Mock(spec_set=Repository)
        type(mock_repo).full_name = 'myuser/foo'
        type(mock_repo).owner = Mock(login='******')
        mock_repo.get_branch.side_effect = se_exc

        with patch('%s.logger' % pbm) as mock_logger:
            res = self.cls.repo_commit_in_last_day(mock_repo)
        assert res is True
        assert mock_repo.mock_calls == [call.get_branch('master')]
        assert mock_logger.mock_calls == [
            call.exception("Unable to get branch %s for repo %s",
                           'master', 'myuser/foo')
        ]
示例#2
0
    def test_repo_commit_in_last_day_true(self):
        mock_repo = Mock(spec_set=Repository)
        type(mock_repo).full_name = 'myuser/foo'
        type(mock_repo).owner = Mock(login='******')

        mock_author = Mock(spec_set=GitAuthor)
        type(mock_author).date = datetime.datetime(2015, 1, 10, 10, 1, 2)
        mock_commit_commit = Mock(spec_set=GitCommit)
        type(mock_commit_commit).author = mock_author
        mock_commit = Mock(spec_set=Commit)
        type(mock_commit).sha = 'myCommitSHA'
        type(mock_commit).commit = mock_commit_commit
        mock_branch = Mock(spec_set=Branch)
        type(mock_branch).commit = mock_commit
        mock_repo.get_branch.return_value = mock_branch

        res = self.cls.repo_commit_in_last_day(mock_repo)
        assert res is True
        assert mock_repo.mock_calls == [call.get_branch('master')]