示例#1
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
            {
                u'user': {
                    u'login': u'reviewer0'
                },
                u'submitted_at': u'2017-02-02T00:00:00Z',
                u'state': u'CHANGES_REQUESTED',
                u'commit_id': u'569597fac8175e6c63cbb415080ce42f9992a0c9'
            },
        ]
        submitter = u'submitter'

        filtered = get_review_state(reviews, submitter)

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

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

        requested_by = changes_requested_by(filtered, shipits, last_commit,
                                            ready_for_review)
        self.assertEqual(
            requested_by,
            [u'reviewer0'])  # HANGES_REQUESTED review isn't ignored
示例#2
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 = u'dce73fdee311d5e74a7d59fd301320943f69d49f'
        reviews = [
            # oldest first
            {
                u'user': {
                    u'login': u'reviewer0'
                },
                u'submitted_at': u'2017-01-01T00:00:00Z',
                u'state': u'CHANGES_REQUESTED',
                u'commit_id': last_commit
            },
        ]
        submitter = u'submitter'

        filtered = get_review_state(reviews, submitter)

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

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

        requested_by = changes_requested_by(filtered, shipits, last_commit,
                                            ready_for_review)
        self.assertEqual(
            requested_by,
            [u'reviewer0'])  # HANGES_REQUESTED review isn't ignored
    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'])
示例#4
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
            {'user': {'login': '******'}, 'submitted_at': '2017-01-01T00:00:00Z', 'state': 'COMMENTED'},

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

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

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

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

        filtered = get_review_state(reviews, submitter)

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

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

        last_commit = 'dce73fdee311d5e74a7d59fd301320943f69d49f'
        requested_by = changes_requested_by(filtered, shipits, last_commit, ready_for_review=None)
        self.assertEqual(sorted(requested_by), ['reviewer3', 'reviewer4'])
    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
            {u'user': {u'login': u'reviewer0'}, u'submitted_at': u'2017-02-02T00:00:00Z', u'state': u'CHANGES_REQUESTED',
             u'commit_id': u'569597fac8175e6c63cbb415080ce42f9992a0c9'},
        ]
        submitter = u'submitter'

        filtered = get_review_state(reviews, submitter)

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

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

        requested_by = changes_requested_by(filtered, shipits, last_commit, ready_for_review)
        self.assertEqual(requested_by, [u'reviewer0'])  # HANGES_REQUESTED review isn't ignored
    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 = u'dce73fdee311d5e74a7d59fd301320943f69d49f'
        reviews = [
            # oldest first
            {u'user': {u'login': u'reviewer0'}, u'submitted_at': u'2017-01-01T00:00:00Z', u'state': u'CHANGES_REQUESTED',
             u'commit_id': last_commit},
        ]
        submitter = u'submitter'

        filtered = get_review_state(reviews, submitter)

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

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

        requested_by = changes_requested_by(filtered, shipits, last_commit, ready_for_review)
        self.assertEqual(requested_by, [u'reviewer0'])  # HANGES_REQUESTED review isn't ignored
示例#7
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
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-01-01T00:00:00Z',
                'state': 'COMMENTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-02-01T00:00:00Z',
                'state': 'COMMENTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-02-02T00:00:00Z',
                'state': 'CHANGES_REQUESTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-02-03T00:00:00Z',
                'state': 'COMMENTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-03-01T00:00:00Z',
                'state': 'CHANGES_REQUESTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-03-02T00:00:00Z',
                'state': 'APPROVED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-03-03T00:00:00Z',
                'state': 'COMMENTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-04-02T00:00:00Z',
                'state': 'APPROVED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-04-03T00:00:00Z',
                'state': 'CHANGES_REQUESTED'
            },
            {
                'user': {
                    'login': '******'
                },
                'submitted_at': '2017-05-01T00:00:00Z',
                'state': 'CHANGES_REQUESTED'
            },
        ]
        submitter = 'submitter'

        filtered = get_review_state(reviews, submitter)

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

        shipits = {
            'reviewer1':
            self.make_time('2017-02-04T00:00:00Z'
                           ),  # newer, overrides CHANGES_REQUESTED review
            'reviewer3': self.make_time(
                '2017-04-01T00:00:00Z'
            ),  # older, doesn't override CHANGES_REQUESTED review
        }
        requested_by = changes_requested_by(filtered, shipits)
        self.assertEqual(sorted(requested_by), ['reviewer3', 'reviewer4'])