diff --git a/zaqar/storage/redis/subscriptions.py b/zaqar/storage/redis/subscriptions.py index 4564a3bdb..700ed6e24 100644 --- a/zaqar/storage/redis/subscriptions.py +++ b/zaqar/storage/redis/subscriptions.py @@ -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)) diff --git a/zaqar/tests/unit/storage/base.py b/zaqar/tests/unit/storage/base.py index d0ec7013f..6fa15ec64 100644 --- a/zaqar/tests/unit/storage/base.py +++ b/zaqar/tests/unit/storage/base.py @@ -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)