Merge "Check body type when patching subscription"
This commit is contained in:
commit
d27e784cfa
@ -364,6 +364,15 @@ class TestSubscriptionsMongoDB(base.V2Base):
|
|||||||
headers=self.headers)
|
headers=self.headers)
|
||||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||||
|
|
||||||
|
def test_patch_invalid_body(self):
|
||||||
|
resp = self.simulate_patch(self.subscription_path + '/x',
|
||||||
|
body='[1]',
|
||||||
|
headers=self.headers)
|
||||||
|
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||||
|
resp_doc = jsonutils.loads(resp[0])
|
||||||
|
self.assertEqual('Subscriptions must be a dict.',
|
||||||
|
resp_doc['description'])
|
||||||
|
|
||||||
def test_delete_works(self):
|
def test_delete_works(self):
|
||||||
self._create_subscription()
|
self._create_subscription()
|
||||||
resp = self.simulate_get(self.subscription_path,
|
resp = self.simulate_get(self.subscription_path,
|
||||||
|
@ -521,6 +521,10 @@ class Validator(object):
|
|||||||
if not subscription:
|
if not subscription:
|
||||||
raise ValidationFailed(_(u'No subscription to create.'))
|
raise ValidationFailed(_(u'No subscription to create.'))
|
||||||
|
|
||||||
|
if not isinstance(subscription, dict):
|
||||||
|
msg = _('Subscriptions must be a dict.')
|
||||||
|
raise ValidationFailed(msg)
|
||||||
|
|
||||||
subscriber = subscription.get('subscriber', None)
|
subscriber = subscription.get('subscriber', None)
|
||||||
subscriber_type = None
|
subscriber_type = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user