Пример #1
0
    def test_update_review(self, m):
        self._patch_conf()
        u_r = update_reviews.UpdateReviews(mock.sentinel.project)

        change_id = mock.sentinel.change_id
        revision_id = mock.sentinel.revision_id

        url_base = 'https://review.openstack.org/'
        url = ('%sa/changes/%s/revisions/%s/review' %
               (url_base, change_id, revision_id))
        m.post(url)

        review = {
            'id': change_id,
            'current_revision': revision_id,
        }

        u_r._update_review(review)

        exp_req = {
            'message': 'This project is now open for new features.',
            'labels': {
                'Code-Review': 0,
            },
        }

        self.assertEqual(exp_req, m.request_history[0].json())
Пример #2
0
def main():

    # Get urllib3 to shut up.
    warnings.simplefilter('ignore', Warning)

    project = sys.argv[1]
    u_r = update_reviews.UpdateReviews(project,
                                       updating_review_cb=updating_review_cb)
    u_r.update_my_reviews()
Пример #3
0
    def test_update_my_reviews(self):
        self._patch_conf()
        u_r = update_reviews.UpdateReviews(mock.sentinel.project)

        sample_reviews = [mock.sentinel.r1, mock.sentinel.r2]
        po = mockpatch.PatchObject(u_r,
                                   '_list_my_reviews',
                                   return_value=sample_reviews)
        list_my_reviews_mock = self.useFixture(po).mock

        update_review_mock = self.useFixture(
            mockpatch.PatchObject(u_r, '_update_review')).mock

        u_r.update_my_reviews()

        self.assertEqual(1, list_my_reviews_mock.call_count)
        exp_calls = [mock.call(mock.sentinel.r1), mock.call(mock.sentinel.r2)]
        self.assertEqual(exp_calls, update_review_mock.call_args_list)
Пример #4
0
    def test_list_my_reviews(self, m):
        self._patch_conf()
        u_r = update_reviews.UpdateReviews(mock.sentinel.project)

        sample_result = []

        gerrit_magic_prefix = ")]}'\n"
        sample_text = '%s%s' % (gerrit_magic_prefix, json.dumps(sample_result))
        m.get('https://review.openstack.org/a/changes/', text=sample_text)
        ret = u_r._list_my_reviews()
        self.assertEqual(sample_result, ret)
        exp_qs = {
            'q': [
                'project:%s branch:master status:open '
                'label:code-review=-2,self' % mock.sentinel.project
            ],
            'o': ['current_revision'],
        }
        self.assertEqual(exp_qs, m.request_history[0].qs)
Пример #5
0
    def test_updating_review_callback(self):
        self._patch_conf()

        cb = mock.Mock()
        u_r = update_reviews.UpdateReviews(mock.sentinel.project,
                                           updating_review_cb=cb)

        sample_reviews = [mock.sentinel.r1, mock.sentinel.r2]
        po = mockpatch.PatchObject(u_r,
                                   '_list_my_reviews',
                                   return_value=sample_reviews)
        self.useFixture(po).mock

        self.useFixture(mockpatch.PatchObject(u_r, '_update_review')).mock

        u_r.update_my_reviews()

        exp_calls = [mock.call(mock.sentinel.r1), mock.call(mock.sentinel.r2)]
        self.assertEqual(exp_calls, cb.call_args_list)