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)
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)
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)
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)
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)
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)
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)
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