Beispiel #1
0
    def test_review_older_than_ready_for_review_PR_not_updated(self):
        """Check that:
        - CHANGES_REQUESTED review older than ready_for_review comment wrote by submitter
        - but submitter didn't update the pull request
        => review isn't ignored
        """
        last_commit = 'dce73fdee311d5e74a7d59fd301320943f69d49f'
        reviews = [
            # oldest first
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-01-01T00:00:00Z',
                'state': 'CHANGES_REQUESTED',
                'commit_id': last_commit
            },
        ]
        submitter = 'submitter'

        filtered = _get_review_state(reviews, submitter)

        self.assertEqual(filtered['reviewer0']['state'], 'CHANGES_REQUESTED')

        shipits = {}
        ready_for_review = self.make_time('2017-02-02T00:00:00Z')

        requested_by = _changes_requested_by(filtered, shipits, last_commit,
                                             ready_for_review)
        self.assertEqual(
            requested_by,
            ['reviewer0'])  # HANGES_REQUESTED review isn't ignored
Beispiel #2
0
    def test_ready_for_review_older_than_review(self):
        """Check that:
        - CHANGES_REQUESTED review younger than ready_for_review comment wrote by submitter
        => review isn't ignored
        """
        reviews = [
            # oldest first
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-02-02T00:00:00Z',
                'state': 'CHANGES_REQUESTED',
                'commit_id': '569597fac8175e6c63cbb415080ce42f9992a0c9'
            },
        ]
        submitter = 'submitter'

        filtered = _get_review_state(reviews, submitter)

        self.assertEqual(filtered['reviewer0']['state'], 'CHANGES_REQUESTED')

        shipits = {}
        last_commit = 'dce73fdee311d5e74a7d59fd301320943f69d49f'
        ready_for_review = self.make_time('2017-01-01T00:00:00Z')

        requested_by = _changes_requested_by(filtered, shipits, last_commit,
                                             ready_for_review)
        self.assertEqual(
            requested_by,
            ['reviewer0'])  # HANGES_REQUESTED review isn't ignored
Beispiel #3
0
    def test_reviews(self):
        """Check that:
        - COMMENTED review aren't ignored (reviewer0)
        - a COMMENTED review doesn't override an older CHANGES_REQUESTED review (reviewer1)
        - a COMMENTED review overrides an older APPROVED review (reviewer2)
        - a CHANGES_REQUESTED review overrides an older APPROVED review (reviewer3)
        """
        reviews = [
            # oldest first
            {u'user': {u'login': u'reviewer0'}, u'submitted_at': u'2017-01-01T00:00:00Z', u'state': u'COMMENTED'},

            {u'user': {u'login': u'reviewer1'}, u'submitted_at': u'2017-02-01T00:00:00Z', u'state': u'COMMENTED'},
            {u'user': {u'login': u'reviewer1'}, u'submitted_at': u'2017-02-02T00:00:00Z', u'state': u'CHANGES_REQUESTED'},
            {u'user': {u'login': u'reviewer1'}, u'submitted_at': u'2017-02-03T00:00:00Z', u'state': u'COMMENTED'},

            {u'user': {u'login': u'reviewer2'}, u'submitted_at': u'2017-03-01T00:00:00Z', u'state': u'CHANGES_REQUESTED'},
            {u'user': {u'login': u'reviewer2'}, u'submitted_at': u'2017-03-02T00:00:00Z', u'state': u'APPROVED'},
            {u'user': {u'login': u'reviewer2'}, u'submitted_at': u'2017-03-03T00:00:00Z', u'state': u'COMMENTED'},

            {u'user': {u'login': u'reviewer3'}, u'submitted_at': u'2017-04-02T00:00:00Z', u'state': u'APPROVED'},
            {u'user': {u'login': u'reviewer3'}, u'submitted_at': u'2017-04-03T00:00:00Z', u'state': u'CHANGES_REQUESTED'},

            {u'user': {u'login': u'reviewer4'}, u'submitted_at': u'2017-05-01T00:00:00Z', u'state': u'CHANGES_REQUESTED'},
        ]
        for review in reviews:
            review[u'commit_id'] = u'569597fac8175e6c63cbb415080ce42f9992a0c9'
        submitter = u'submitter'

        filtered = _get_review_state(reviews, submitter)

        self.assertEqual(filtered[u'reviewer0'][u'state'], u'COMMENTED')
        self.assertEqual(filtered[u'reviewer1'][u'state'], u'CHANGES_REQUESTED')
        self.assertEqual(filtered[u'reviewer2'][u'state'], u'COMMENTED')
        self.assertEqual(filtered[u'reviewer3'][u'state'], u'CHANGES_REQUESTED')
        self.assertEqual(filtered[u'reviewer4'][u'state'], u'CHANGES_REQUESTED')

        shipits = {
            u'reviewer1': self.make_time(u'2017-02-04T00:00:00Z'),  # newer, overrides CHANGES_REQUESTED review
            u'reviewer3': self.make_time(u'2017-04-01T00:00:00Z'),  # older, doesn't override CHANGES_REQUESTED review
        }

        last_commit = u'dce73fdee311d5e74a7d59fd301320943f69d49f'
        requested_by = _changes_requested_by(filtered, shipits, last_commit, ready_for_review=None)
        self.assertEqual(sorted(requested_by), [u'reviewer3', u'reviewer4'])