Ejemplo n.º 1
0
    def test_get_change_not_modified(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API with Not Modified response"""
        review_request = self.create_review_request()

        changedesc = ChangeDescription(public=True)
        changedesc.save()
        review_request.changedescs.add(changedesc)

        self._testHttpCaching(get_change_item_url(changedesc), check_last_modified=True)
Ejemplo n.º 2
0
    def test_put_method_not_allowed(self):
        """Testing the PUT review-requests/<id>/changes/ API
        gives Method Not Allowed
        """
        review_request = self.create_review_request()

        change = ChangeDescription.objects.create(public=True)
        review_request.changedescs.add(change)

        self.api_put(get_change_item_url(change), {}, expected_status=405)
Ejemplo n.º 3
0
    def test_put_method_not_allowed(self):
        """Testing the PUT review-requests/<id>/changes/ API
        gives Method Not Allowed
        """
        review_request = self.create_review_request()

        change = ChangeDescription.objects.create(public=True)
        review_request.changedescs.add(change)

        self.apiPut(get_change_item_url(change), {}, expected_status=405)
Ejemplo n.º 4
0
    def test_get_change_not_modified(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API with Not Modified response"""
        review_request = self.create_review_request()

        changedesc = ChangeDescription(public=True)
        changedesc.save()
        review_request.changedescs.add(changedesc)

        self._testHttpCaching(get_change_item_url(changedesc),
                              check_last_modified=True)
Ejemplo n.º 5
0
    def test_get_with_site_no_access(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API
        without access to a local site
        """
        review_request = self.create_review_request(publish=True,
                                                    with_local_site=True)

        now = timezone.now()
        change = ChangeDescription(public=True, timestamp=now)
        change.record_field_change('summary', 'foo', 'bar')
        change.save()
        review_request.changedescs.add(change)

        rsp = self.api_get(get_change_item_url(change, self.local_site_name),
                           expected_status=403)
        self.assertEqual(rsp['stat'], 'fail')
        self.assertEqual(rsp['err']['code'], PERMISSION_DENIED.code)
Ejemplo n.º 6
0
    def test_get_with_site_no_access(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API
        without access to a local site
        """
        review_request = self.create_review_request(publish=True,
                                                    with_local_site=True)

        now = timezone.now()
        change = ChangeDescription(public=True, timestamp=now)
        change.record_field_change('summary', 'foo', 'bar')
        change.save()
        review_request.changedescs.add(change)

        rsp = self.apiGet(
            get_change_item_url(change, self.local_site_name),
            expected_status=403)
        self.assertEqual(rsp['stat'], 'fail')
        self.assertEqual(rsp['err']['code'], PERMISSION_DENIED.code)
Ejemplo n.º 7
0
    def test_get_with_site(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API
        with access to a local site
        """
        review_request = self.create_review_request(publish=True,
                                                    with_local_site=True)

        self._login_user(local_site=True)

        now = timezone.now()
        change = ChangeDescription(public=True, timestamp=now)
        change.record_field_change('summary', 'foo', 'bar')
        change.save()
        review_request.changedescs.add(change)

        rsp = self.api_get(get_change_item_url(change, self.local_site_name),
                           expected_mimetype=change_item_mimetype)
        self.assertEqual(rsp['stat'], 'ok')
        self.assertEqual(rsp['change']['id'], change.pk)
Ejemplo n.º 8
0
    def test_get_with_site(self):
        """Testing the GET review-requests/<id>/changes/<id>/ API
        with access to a local site
        """
        review_request = self.create_review_request(publish=True,
                                                    with_local_site=True)

        self._login_user(local_site=True)

        now = timezone.now()
        change = ChangeDescription(public=True, timestamp=now)
        change.record_field_change('summary', 'foo', 'bar')
        change.save()
        review_request.changedescs.add(change)

        rsp = self.apiGet(
            get_change_item_url(change, self.local_site_name),
            expected_mimetype=change_item_mimetype)
        self.assertEqual(rsp['stat'], 'ok')
        self.assertEqual(rsp['change']['id'], change.pk)
Ejemplo n.º 9
0
    def setup_review_request_child_test(self, review_request):
        change = ChangeDescription.objects.create(public=True)
        review_request.changedescs.add(change)

        return get_change_item_url(change), change_item_mimetype
Ejemplo n.º 10
0
    def setup_review_request_child_test(self, review_request):
        change = ChangeDescription.objects.create(public=True)
        review_request.changedescs.add(change)

        return get_change_item_url(change), change_item_mimetype