Skip to content

Commit

Permalink
[fc] Repository: plone.batching
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2015-07-09T15:35:45+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: plone/plone.batching@62737b7

PEP8

Files changed:
M plone/batching/tests.py
Repository: plone.batching
Branch: refs/heads/master
Date: 2015-07-09T15:37:27+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: plone/plone.batching@fd08400

PEP8

Files changed:
M plone/batching/tests.py
Repository: plone.batching
Branch: refs/heads/master
Date: 2015-07-09T16:59:39+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: plone/plone.batching@760cf78

Avoid
Module plone.batching.batch, line 232, in previous_pages
ValueError: XXX is not in list
that can happen if b_start is too high and using orphan
See plone/Products.CMFPlone#639

Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py
Repository: plone.batching
Branch: refs/heads/master
Date: 2015-07-09T17:07:55+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: plone/plone.batching@18cc2b7

Really need to compute _pagenumber when using orphan

Files changed:
M plone/batching/batch.py
M plone/batching/tests.py
Repository: plone.batching
Branch: refs/heads/master
Date: 2015-07-15T13:10:07+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: plone/plone.batching@4659033

Merge pull request #8 from gbastien/master

fix for "plone.batching fails if b_start is too high" see plone/Products.CMFPlone#639

Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py
  • Loading branch information
jensens committed Jul 15, 2015
1 parent da89d63 commit c1ae34d
Showing 1 changed file with 303 additions and 21 deletions.
324 changes: 303 additions & 21 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,317 @@
Repository: plone.app.multilingual
Repository: plone.batching


Branch: refs/heads/master
Date: 2015-07-15T13:07:07+02:00
Author: Ramon Navarro Bosch (bloodbare) <ramon.nb@gmail.com>
Commit: https://github.com/plone/plone.app.multilingual/commit/3feba811cb65f7f358ea86d1c4cac23cf44b24f5
Date: 2015-07-09T15:35:45+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: https://github.com/plone/plone.batching/commit/62737b7c917226e99627458f6c52b34401ce9b9f

Waiting for patterns to test the add translation on robot framework
PEP8

Files changed:
M src/plone/app/multilingual/tests/robot/test_add_translation.robot
M plone/batching/tests.py

diff --git a/src/plone/app/multilingual/tests/robot/test_add_translation.robot b/src/plone/app/multilingual/tests/robot/test_add_translation.robot
index 3352501..1db12e1 100644
--- a/src/plone/app/multilingual/tests/robot/test_add_translation.robot
+++ b/src/plone/app/multilingual/tests/robot/test_add_translation.robot
@@ -2,6 +2,7 @@
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index c0e7853..9737ca8 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -194,8 +194,7 @@ def test_batchview_plone(self):
request = TestRequest(form={'a': 'foo', 'c': 'bar'})
setattr(request, 'ACTUAL_URL', 'http://nohost/dummy')
view = PloneBatchView(None, request)
- rendered = view(batch, ['a', 'b'])
-
+ view(batch, ['a', 'b'])
self.assertEqual(view.make_link(3),
'http://nohost/dummy?a=foo&b_start:int=6')

Resource plone/app/robotframework/selenium.robot
Resource plone/app/robotframework/keywords.robot
+Resource Products/CMFPlone/tests/robot/keywords.robot


Repository: plone.batching


Branch: refs/heads/master
Date: 2015-07-09T15:37:27+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: https://github.com/plone/plone.batching/commit/fd08400d954fb25b45a501fbe8c14530ec68b6c7

PEP8

Files changed:
M plone/batching/tests.py

diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index 9737ca8..708f719 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -109,7 +109,8 @@ def test_lastpage_with_orphans(self):
def test_items_not_on_page(self):
batch = BaseBatch(range(20), 5, start=5)
self.assertEqual(batch.items_not_on_page,
- [0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
+ [0, 1, 2, 3, 4, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19])
self.assertEqual(list(batch), [5, 6, 7, 8, 9])

def test_batch_bsize(self):


Repository: plone.batching


Branch: refs/heads/master
Date: 2015-07-09T16:59:39+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: https://github.com/plone/plone.batching/commit/760cf783456e4d1985b238f16379932fce06ef63

Avoid
Module plone.batching.batch, line 232, in previous_pages
ValueError: XXX is not in list
that can happen if b_start is too high and using orphan
See https://github.com/plone/Products.CMFPlone/issues/639

Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 54c839e..b1dd523 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
1.0.5 (unreleased)
------------------

-- Nothing changed yet.
+- Make sure pagenumber value is not bigger that numpages
+ or it fails in previous_pages when using orphan
+ [gbastien]


1.0.4 (2015-04-28)
diff --git a/plone/batching/batch.py b/plone/batching/batch.py
index 817a2b2..30caa7e 100644
--- a/plone/batching/batch.py
+++ b/plone/batching/batch.py
@@ -56,19 +56,22 @@ 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

# Set up the total number of pages
self.numpages = calculate_pagenumber(
self.sequence_length - self.orphan, self.pagesize, self.overlap)

- # Set up the current page number
- self._pagenumber = calculate_pagenumber(
- self.start, self.pagesize, self.overlap)
+ if self.beyond:
+ self.first = self.end
+ # Make sure current page number is not > numpages
+ self._pagenumber = self.numpages
+ else:
+ # Set up the current page number
+ self._pagenumber = calculate_pagenumber(
+ self.start, self.pagesize, self.overlap)
+
+ self.length = self.end - self.first

@property
def navlist(self):
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index 708f719..8680021 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -156,6 +156,17 @@ def test_multiple_pages_longer(self):
batch = BaseBatch(range(12), 10)
self.assertEquals(batch.multiple_pages, True)

+ def test_pagenumber_never_over_numpages(self):
+ """computed _pagenumber is never > numpages, this
+ makes previous_pages not fail."""
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7], 3, 8)
+ self.assertEquals(batch.previous_pages, [1, 2])
+ self.assertEquals(batch._pagenumber, 3)
+ # works especially with orphan
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7], 3, 8, orphan=2)
+ self.assertEquals(batch.previous_pages, [1])
+ self.assertEquals(batch._pagenumber, 2)
+

class TestQuantumBatch(unittest.TestCase):



Repository: plone.batching


Branch: refs/heads/master
Date: 2015-07-09T17:07:55+02:00
Author: Gauthier Bastien (gbastien) <g.bastien@imio.be>
Commit: https://github.com/plone/plone.batching/commit/18cc2b779b4885f59019a11633544b0d10baa8e7

Really need to compute _pagenumber when using orphan

Files changed:
M plone/batching/batch.py
M plone/batching/tests.py

diff --git a/plone/batching/batch.py b/plone/batching/batch.py
index 30caa7e..cb30b1e 100644
--- a/plone/batching/batch.py
+++ b/plone/batching/batch.py
@@ -56,22 +56,23 @@ 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

# Set up the total number of pages
self.numpages = calculate_pagenumber(
self.sequence_length - self.orphan, self.pagesize, self.overlap)

- if self.beyond:
- self.first = self.end
- # Make sure current page number is not > numpages
- self._pagenumber = self.numpages
- else:
- # Set up the current page number
- self._pagenumber = calculate_pagenumber(
- self.start, self.pagesize, self.overlap)
+ # Set up the current page number
+ self._pagenumber = calculate_pagenumber(
+ self.start, self.pagesize, self.overlap)

- self.length = self.end - self.first
+ # Make sure self._pagenumber is <= self.numpages
+ if self._pagenumber > self.numpages:
+ self._pagenumber = self.numpages

@property
def navlist(self):
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index 8680021..eda6168 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -159,13 +159,13 @@ def test_multiple_pages_longer(self):
def test_pagenumber_never_over_numpages(self):
"""computed _pagenumber is never > numpages, this
makes previous_pages not fail."""
- batch = BaseBatch([1, 2, 3, 4, 5, 6, 7], 3, 8)
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 9)
+ self.assertEquals(batch.previous_pages, [1, 2, 3])
+ self.assertEquals(batch._pagenumber, 4)
+ # works especially with orphan
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 9, orphan=2)
self.assertEquals(batch.previous_pages, [1, 2])
self.assertEquals(batch._pagenumber, 3)
- # works especially with orphan
- batch = BaseBatch([1, 2, 3, 4, 5, 6, 7], 3, 8, orphan=2)
- self.assertEquals(batch.previous_pages, [1])
- self.assertEquals(batch._pagenumber, 2)


class TestQuantumBatch(unittest.TestCase):


Repository: plone.batching


Branch: refs/heads/master
Date: 2015-07-15T13:10:07+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.batching/commit/46590330f90f1439bcca2948bb672fd12e5a97bd

Merge pull request #8 from gbastien/master

fix for "plone.batching fails if b_start is too high" see plone/Products.CMFPlone#639

Files changed:
M CHANGES.rst
M plone/batching/batch.py
M plone/batching/tests.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 54c839e..b1dd523 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
1.0.5 (unreleased)
------------------

-- Nothing changed yet.
+- Make sure pagenumber value is not bigger that numpages
+ or it fails in previous_pages when using orphan
+ [gbastien]


1.0.4 (2015-04-28)
diff --git a/plone/batching/batch.py b/plone/batching/batch.py
index 817a2b2..cb30b1e 100644
--- a/plone/batching/batch.py
+++ b/plone/batching/batch.py
@@ -70,6 +70,10 @@ def initialize(self, start, end, size):
self._pagenumber = calculate_pagenumber(
self.start, self.pagesize, self.overlap)

+ # Make sure self._pagenumber is <= self.numpages
+ if self._pagenumber > self.numpages:
+ self._pagenumber = self.numpages
+
@property
def navlist(self):
""" Pagenumber list for creating batch links """
diff --git a/plone/batching/tests.py b/plone/batching/tests.py
index c0e7853..eda6168 100644
--- a/plone/batching/tests.py
+++ b/plone/batching/tests.py
@@ -109,7 +109,8 @@ def test_lastpage_with_orphans(self):
def test_items_not_on_page(self):
batch = BaseBatch(range(20), 5, start=5)
self.assertEqual(batch.items_not_on_page,
- [0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
+ [0, 1, 2, 3, 4, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19])
self.assertEqual(list(batch), [5, 6, 7, 8, 9])

def test_batch_bsize(self):
@@ -155,6 +156,17 @@ def test_multiple_pages_longer(self):
batch = BaseBatch(range(12), 10)
self.assertEquals(batch.multiple_pages, True)

Library Remote ${PLONE_URL}/RobotRemote
+ def test_pagenumber_never_over_numpages(self):
+ """computed _pagenumber is never > numpages, this
+ makes previous_pages not fail."""
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 9)
+ self.assertEquals(batch.previous_pages, [1, 2, 3])
+ self.assertEquals(batch._pagenumber, 4)
+ # works especially with orphan
+ batch = BaseBatch([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 9, orphan=2)
+ self.assertEquals(batch.previous_pages, [1, 2])
+ self.assertEquals(batch._pagenumber, 3)
+

@@ -51,6 +52,7 @@ I add the document in English as a translation
Wait until element is visible css=#_add_translations
class TestQuantumBatch(unittest.TestCase):

Click Element css=#_add_translations
+ Given patterns are loaded
Wait until page contains element
... css=#formfield-form-widgets-content .select2-choices
@@ -194,8 +206,7 @@ def test_batchview_plone(self):
request = TestRequest(form={'a': 'foo', 'c': 'bar'})
setattr(request, 'ACTUAL_URL', 'http://nohost/dummy')
view = PloneBatchView(None, request)
- rendered = view(batch, ['a', 'b'])
-
+ view(batch, ['a', 'b'])
self.assertEqual(view.make_link(3),
'http://nohost/dummy?a=foo&b_start:int=6')



0 comments on commit c1ae34d

Please sign in to comment.