[PATCH v3 06/10] REST: Add Patch Checks to the API

Andy Doan andy.doan at linaro.org
Sat May 21 06:13:02 AEST 2016


On 05/19/2016 04:26 AM, Finucane, Stephen wrote:
>> +    def test_create(self):
>> >+        """Ensure creations can be performed by user of patch."""
>> >+        check = {
>> >+            'state': 'success',
>> >+            'target_url': 'http://t.co',
>> >+            'description': 'description',
>> >+            'context': 'context',
>> >+        }
>> >+
>> >+        self.client.force_authenticate(user=self.user)
>> >+        resp = self.client.post(self.urlbase, check)
>> >+        self.assertEqual(status.HTTP_201_CREATED, resp.status_code)
>> >+        self.assertEqual(1, Check.objects.all().count())
>> >+
>> >+        user = create_user()
>> >+        self.client.force_authenticate(user=user)
>> >+        resp = self.client.post(self.urlbase, check)
>> >+        self.assertEqual(status.HTTP_403_FORBIDDEN, resp.status_code)

You get a 400 "Bad Request" response. I went ahead and added a test to 
assert this.


More information about the Patchwork mailing list