Esempio n. 1
0
    def test_error_no_author_on_commit(self, m1):
        from mr.roboto.events import NewPullRequest

        class FakeCommitsData(object):
            def json(self):
                return [{
                    'committer': {
                        'login': '******'
                    },
                    'author': None,
                    'commit': {
                        'author': {
                            'name': 'My name'
                        }
                    },
                }]

        m1.return_value = FakeCommitsData()

        event = NewPullRequest(pull_request=PAYLOAD, request=MockRequest())

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertIn('does not have author user info',
                      captured_data.records[0].msg)
Esempio n. 2
0
    def test_no_plone_org_also_works(self, m1):
        from mr.roboto.events import NewPullRequest

        class FakeCommitsData(object):
            def json(self):
                return [{
                    'committer': {
                        'login': '******'
                    },
                    'author': {
                        'login': '******'
                    },
                    'commit': {
                        'author': {
                            'name': 'My name'
                        }
                    },
                }]

        m1.return_value = FakeCommitsData()

        event = NewPullRequest(pull_request=COLLECTIVE_PAYLOAD,
                               request=MockRequest())

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertIn('Contributors Agreement report: success',
                      captured_data.records[-1].msg)
Esempio n. 3
0
    def test_no_foundation_member(self, m1):
        from mr.roboto.events import NewPullRequest

        class FakeCommitsData(object):
            def json(self):
                return [{
                    'committer': {
                        'login': '******'
                    },
                    'author': {
                        'login': '******'
                    }
                }]

        m1.return_value = FakeCommitsData()

        inner_mock = mock.MagicMock()
        inner_mock.has_in_members.return_value = False
        mock_obj = mock.MagicMock()
        mock_obj.get_organization.return_value = inner_mock
        settings = {'github': mock_obj}

        request = MockRequest()
        request.settings = settings

        event = NewPullRequest(pull_request=PAYLOAD, request=request)

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertEqual(len(captured_data.records), 1)
        self.assertIn('Contributors Agreement report: error',
                      captured_data.records[0].msg)
Esempio n. 4
0
    def test_whitelisted(self):
        from mr.roboto.events import NewPullRequest

        event = NewPullRequest(pull_request=WHITELISTED_PAYLOAD,
                               request=MockRequest())

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertIn('whitelisted for contributors agreement',
                      captured_data.records[-1].msg)
Esempio n. 5
0
    def test_error_getting_commits(self, m1):
        from mr.roboto.events import NewPullRequest
        from requests.exceptions import ReadTimeout

        m1.side_effect = ReadTimeout()

        event = NewPullRequest(pull_request=PAYLOAD, request=MockRequest())

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertEqual(len(captured_data.records), 1)
        self.assertIn('error while trying to get its commits',
                      captured_data.records[0].msg)
Esempio n. 6
0
    def test_error_parsing_commits_data(self, m1):
        from mr.roboto.events import NewPullRequest

        class FakeCommitsData(object):
            def json(self):
                raise ValueError()

        m1.return_value = FakeCommitsData()

        event = NewPullRequest(pull_request=PAYLOAD, request=MockRequest())

        with LogCapture() as captured_data:
            ContributorsAgreementSigned(event)

        self.assertEqual(len(captured_data.records), 1)
        self.assertIn('error while getting its commits in JSON',
                      captured_data.records[0].msg)