Skip to content

Commit

Permalink
Improve testing for single item batch. Only fix self.first if sequenc…
Browse files Browse the repository at this point in the history
…e is bigger than one
  • Loading branch information
Peter Uittenbroek committed Mar 5, 2014
1 parent 7457f41 commit 3eaaab6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plone/batching/batch.py
Expand Up @@ -51,7 +51,7 @@ def initialize(self, start, end, size):
self.end = end

self.first = max(start - 1, 0)
if self.start == self.end:
if self.start == self.end and self.sequence_length > 1:
self.first = self.end
self.length = self.end - self.first

Expand Down
4 changes: 4 additions & 0 deletions plone/batching/tests.py
Expand Up @@ -118,6 +118,10 @@ def test_batch_bsize(self):
batch = BaseBatch(sequence, 10, start=280)
self.assertEqual(batch.length, 0)

# Single item batch
batch = BaseBatch(sequence[0:1], 10)
self.assertEqual(batch.length, 1)


class TestQuantumBatch(unittest.TestCase):

Expand Down

0 comments on commit 3eaaab6

Please sign in to comment.