Merge "Don't return links if subscriptions are empty"

This commit is contained in:
Jenkins 2016-02-17 15:13:15 +00:00 committed by Gerrit Code Review
commit b24be72fde
2 changed files with 14 additions and 1 deletions

View File

@ -176,6 +176,19 @@ class TestSubscriptionsMongoDB(base.V2Base):
def test_list_works(self): def test_list_works(self):
self._list_subscription() self._list_subscription()
def test_list_empty(self):
resp = self.simulate_get(self.subscription_path,
headers=self.headers)
self.assertEqual(falcon.HTTP_200, self.srmock.status)
resp_doc = jsonutils.loads(resp[0])
self.assertIsInstance(resp_doc, dict)
self.assertIn('subscriptions', resp_doc)
self.assertIn('links', resp_doc)
self.assertEqual([], resp_doc['subscriptions'])
self.assertEqual([], resp_doc['links'])
@ddt.data(1, 5, 10, 15) @ddt.data(1, 5, 10, 15)
def test_listing_works_with_limit(self, limit): def test_listing_works_with_limit(self, limit):
self._list_subscription(count=15, limit=limit) self._list_subscription(count=15, limit=limit)

View File

@ -142,7 +142,7 @@ class CollectionResource(object):
kwargs['marker'] = next(results) or kwargs.get('marker', '') kwargs['marker'] = next(results) or kwargs.get('marker', '')
links = [] links = []
if results: if subscriptions:
links = [ links = [
{ {
'rel': 'next', 'rel': 'next',