Merge "Fix issue with subscription list in Redis"

This commit is contained in:
Jenkins 2016-07-04 20:23:51 +00:00 committed by Gerrit Code Review
commit 39be4c7d58
2 changed files with 26 additions and 1 deletions

View File

@ -60,7 +60,7 @@ class SubscriptionController(base.Subscription):
project,
SUBSCRIPTION_IDS_SUFFIX)
rank = client.zrank(subset_key, marker)
start = rank + 1 if rank else 0
start = rank + 1 if rank is not None else 0
cursor = (q for q in client.zrange(subset_key, start,
start + limit - 1))

View File

@ -1053,6 +1053,31 @@ class SubscriptionControllerTest(ControllerBaseTest):
subscriptions)))
self.assertEqual(5, len(subscriptions))
def test_small_list(self):
subscriber = 'http://fake'
s_id = self.subscription_controller.create(
self.source,
subscriber,
self.ttl,
self.options,
project=self.project)
self.addCleanup(self.subscription_controller.delete, self.source,
s_id, self.project)
interaction = self.subscription_controller.list(self.source,
project=self.project)
subscriptions = list(next(interaction))
marker = next(interaction)
self.assertEqual(1, len(subscriptions))
interaction = (self.subscription_controller.list(self.source,
project=self.project,
marker=marker))
subscriptions = list(next(interaction))
self.assertEqual([], subscriptions)
@ddt.data(True, False)
def test_get_raises_if_subscription_does_not_exist(self, precreate_queue):
self._precreate_queue(precreate_queue)