[Testbot] Plone 5.0 - Python 2.7 - Build # 1906 - Still failing! - 2 failure(s)
jenkins at plone.org
jenkins at plone.org
Mon Mar 10 17:39:24 UTC 2014
-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 1906 - Still Failing!
-------------------------------------------------------------------------------
http://jenkins.plone.org/job/plone-5.0-python-2.7/1906/
-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------
Repository: plone.batching
Branch: refs/heads/master
Date: 2014-03-10T09:14:36+01:00
Author: Peter Uittenbroek (thepjot) <uittenbroek at goldmund-wyldebeast-wunderliebe.com>
Commit: https://github.com/plone/plone.batching/commit/0caf7b213dd024f65b21c954952791dc3f922958
If start is beyond the range of the sequence. Set a flag saying so, so we can prevent the batch from spewing out the last item
Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py
diff --git a/CHANGES.rst b/CHANGES.rst
index 9fa2b30..ac9a5fe 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
1.0.2 (unreleased)
------------------
-- Nothing changed yet.
+- Fix issue where a start >= end will always return last item.
+ https://dev.plone.org/ticket/13880\
+ [thepjot]
1.0.1 (2014-01-27)
diff --git a/plone/batching/batch.py b/plone/batching/batch.py
index 07f4c3d..bb803ce 100644
--- a/plone/batching/batch.py
+++ b/plone/batching/batch.py
@@ -37,7 +37,10 @@ def __init__(self, sequence, size, start=0, end=0, orphan=0, overlap=0,
self.orphan = orphan
self.overlap = overlap
self.pagerange = pagerange
-
+ self.beyond = False
+ # Special use case, where the start is bigger than the sequence
+ if start > len(sequence):
+ self.beyond = True
self.initialize(start, end, size)
def initialize(self, start, end, size):
@@ -51,6 +54,8 @@ def initialize(self, start, end, size):
self.end = end
self.first = max(start - 1, 0)
+ if self.beyond:
+ self.first = self.end
self.length = self.end - self.first
self.last = self.sequence_length - size
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index 2d6e526..2988c2d 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -104,6 +104,36 @@ def test_items_not_on_page(self):
self.assertEqual(list(batch), [5, 6, 7, 8, 9])
+ def test_batch_bsize(self):
+ sequence = range(279)
+ # Random page
+ batch = BaseBatch(sequence, 10, start=80)
+ self.assertEqual(batch.length, 10)
+
+ # Last page
+ batch = BaseBatch(sequence, 10, start=270)
+ self.assertEqual(batch.length, 9)
+
+ # Beyond last page
+ batch = BaseBatch(sequence, 10, start=280)
+ self.assertEqual(batch.length, 0)
+
+ # Single item batch
+ batch = BaseBatch(range(1), 10)
+ self.assertEqual(batch.length, 1)
+
+ # Small sequence batch (to cover plone.z3cform.crud)
+ small_sequence = range(3)
+ # Page 1
+ batch = BaseBatch.fromPagenumber(small_sequence, 2, 1)
+ self.assertEqual(batch.length, 2)
+
+ # Page 2
+ batch = BaseBatch.fromPagenumber(small_sequence, 2, 2)
+ self.assertEqual(batch.length, 1)
+
+
+
class TestQuantumBatch(unittest.TestCase):
def test_quantumbatch(self):
Repository: plone.batching
Branch: refs/heads/master
Date: 2014-03-10T09:49:09-07:00
Author: David Glick (davisagli) <david at glicksoftware.com>
Commit: https://github.com/plone/plone.batching/commit/c533d0b68da0abe47e5c731e4a42e5f3916e685f
Merge pull request #3 from plone/fix-13880-new
Fix 13880
Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py
diff --git a/CHANGES.rst b/CHANGES.rst
index 9fa2b30..ac9a5fe 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
1.0.2 (unreleased)
------------------
-- Nothing changed yet.
+- Fix issue where a start >= end will always return last item.
+ https://dev.plone.org/ticket/13880\
+ [thepjot]
1.0.1 (2014-01-27)
diff --git a/plone/batching/batch.py b/plone/batching/batch.py
index 07f4c3d..bb803ce 100644
--- a/plone/batching/batch.py
+++ b/plone/batching/batch.py
@@ -37,7 +37,10 @@ def __init__(self, sequence, size, start=0, end=0, orphan=0, overlap=0,
self.orphan = orphan
self.overlap = overlap
self.pagerange = pagerange
-
+ self.beyond = False
+ # Special use case, where the start is bigger than the sequence
+ if start > len(sequence):
+ self.beyond = True
self.initialize(start, end, size)
def initialize(self, start, end, size):
@@ -51,6 +54,8 @@ def initialize(self, start, end, size):
self.end = end
self.first = max(start - 1, 0)
+ if self.beyond:
+ self.first = self.end
self.length = self.end - self.first
self.last = self.sequence_length - size
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index 2d6e526..2988c2d 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -104,6 +104,36 @@ def test_items_not_on_page(self):
self.assertEqual(list(batch), [5, 6, 7, 8, 9])
+ def test_batch_bsize(self):
+ sequence = range(279)
+ # Random page
+ batch = BaseBatch(sequence, 10, start=80)
+ self.assertEqual(batch.length, 10)
+
+ # Last page
+ batch = BaseBatch(sequence, 10, start=270)
+ self.assertEqual(batch.length, 9)
+
+ # Beyond last page
+ batch = BaseBatch(sequence, 10, start=280)
+ self.assertEqual(batch.length, 0)
+
+ # Single item batch
+ batch = BaseBatch(range(1), 10)
+ self.assertEqual(batch.length, 1)
+
+ # Small sequence batch (to cover plone.z3cform.crud)
+ small_sequence = range(3)
+ # Page 1
+ batch = BaseBatch.fromPagenumber(small_sequence, 2, 1)
+ self.assertEqual(batch.length, 2)
+
+ # Page 2
+ batch = BaseBatch.fromPagenumber(small_sequence, 2, 2)
+ self.assertEqual(batch.length, 1)
+
+
+
class TestQuantumBatch(unittest.TestCase):
def test_quantumbatch(self):
-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 5825 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140310/e9e54c23/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 123673 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140310/e9e54c23/attachment-0003.obj>
More information about the Testbot
mailing list