Skip to content

Commit

Permalink
[fc] Repository: plone.app.robotframework
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2017-03-14T15:17:12+01:00
Author: Stephan Geulette (sgeulette) <s.geulette@imio.be>
Commit: plone/plone.app.robotframework@9ecc1ca

Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py
Repository: plone.app.robotframework
Branch: refs/heads/master
Date: 2017-03-14T16:30:08+02:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: plone/plone.app.robotframework@fdac6b1

Merge pull request #65 from IMIO/master

Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py
  • Loading branch information
datakurre committed Mar 14, 2017
1 parent 54a260e commit 0e9180f
Showing 1 changed file with 115 additions and 177 deletions.
292 changes: 115 additions & 177 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,212 +1,150 @@
Repository: Products.CMFPlone
Repository: plone.app.robotframework


Branch: refs/heads/master
Date: 2017-03-09T09:54:08+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/Products.CMFPlone/commit/101b1f044ada3f3f0db92690c46db754ebc2623f
Date: 2017-03-14T15:17:12+01:00
Author: Stephan Geulette (sgeulette) <s.geulette@imio.be>
Commit: https://github.com/plone/plone.app.robotframework/commit/9ecc1ca425dea6871ba687c0b94e37aa53a23971

Wrong use of assertTrue in testResourceRegistries
Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M Products/CMFPlone/tests/testResourceRegistries.py
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 4550eea..7efcc4d 100644
index 6af5242..7b7124b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -36,6 +36,9 @@ Bug fixes:
This solves a problem, where Editors couldn't see inactive content, even though they had the required permission on a subpath of the portal (e.g. a subsite).
[thet]
@@ -10,7 +10,8 @@ king changes:

+- Test: Wrong use of assertTrue in testResourceRegistries.
+ [jensens]
+
New features:

5.1b2 (2017-02-20)
------------------
diff --git a/Products/CMFPlone/tests/testResourceRegistries.py b/Products/CMFPlone/tests/testResourceRegistries.py
index 1806dc7..72c7e42 100644
--- a/Products/CMFPlone/tests/testResourceRegistries.py
+++ b/Products/CMFPlone/tests/testResourceRegistries.py
@@ -306,8 +306,10 @@ def test_insert_after(self):
""")
importer._importNode(foobar.documentElement)
resources = self._get_legacy_bundle().resources
- self.assertTrue(resources.index('one') + 1,
- resources.index('foobar-js'))
+ self.assertEqual(
+ resources.index('one') + 1,
+ resources.index('foobar-js')
+ )
-- *add item here*
+- Manage datetime and date field types in "set field value" keyword
+ [sgeulette]

def test_insert_before(self):
importer = self._get_importer()
@@ -326,8 +328,10 @@ def test_insert_before(self):
""")
importer._importNode(foobar.documentElement)
resources = self._get_legacy_bundle().resources
- self.assertTrue(resources.index('one') - 1,
- resources.index('foobar-js'))
+ self.assertEqual(
+ resources.index('one') - 1,
+ resources.index('foobar-js')
+ )
Bug fixes:

def test_be_able_to_disable_but_not_remove(self):
importer = self._get_importer()


Repository: Products.CMFPlone


Branch: refs/heads/master
Date: 2017-03-09T20:21:56+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/Products.CMFPlone/commit/078e8a863631e0c715f19a4bcc18a5c643e9529f

fix: insert-before in legacy resource import was broken

Files changed:
M CHANGES.rst
M Products/CMFPlone/resources/exportimport/resourceregistry.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 7efcc4d..f378854 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -39,6 +39,9 @@ Bug fixes:
- Test: Wrong use of assertTrue in testResourceRegistries.
[jensens]

+- Fix issue popped iup after fix of use of assertTrue in testResourceRegistries: insert-before in legacy resource import was broken.
+ [jensens]
+

5.1b2 (2017-02-20)
------------------
diff --git a/Products/CMFPlone/resources/exportimport/resourceregistry.py b/Products/CMFPlone/resources/exportimport/resourceregistry.py
index 6e636ed..a0343d0 100644
--- a/Products/CMFPlone/resources/exportimport/resourceregistry.py
+++ b/Products/CMFPlone/resources/exportimport/resourceregistry.py
@@ -41,7 +41,7 @@ class ResourceRegistryNodeAdapter(XMLAdapterBase):
diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index f1a29c0..71b2897 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -22,6 +22,7 @@
- Roman Kozlovskyi
- Silvio Tomatis
- Steffen Lindner
+- Stephan Geulette
- Timo Stollenwerk
- Victor Fernandez de Alba
- zotya
diff --git a/src/plone/app/robotframework/content.py b/src/plone/app/robotframework/content.py
index c33e065..adde094 100644
--- a/src/plone/app/robotframework/content.py
+++ b/src/plone/app/robotframework/content.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from datetime import datetime
import os

resource_blacklist = set()
registry = None
-
+
def _importNode(self, node):
"""Import the object from the DOM node.
"""
@@ -140,12 +140,12 @@ def _importNode(self, node):
elif position[0] == 'before':
if position[1] in legacy.resources:
legacy.resources.insert(
- legacy.resources.index(position[1]) + 1,
+ legacy.resources.index(position[1]),
res_id)
else:
legacy.resources.append(res_id)
- if remove:
+ elif remove:
if res_id in legacy.resources:
legacy.resources.remove(res_id)
if res_id in resources:


Repository: Products.CMFPlone
from Products.CMFCore.utils import getToolByName
@@ -173,6 +174,20 @@ def set_field_value(self, uid, field, value, field_type):
value = int(value)
if field_type == 'list':
value = eval(value)
+ if field_type.startswith('datetime'):
+ # field_type must begin with 'datetime'
+ # followed by optional format 'datetime%Y%m%d%H%M'
+ # without format: %Y%m%d%H%M is used
+ field_type = field_type[8:]
+ fmt = field_type and field_type or '%Y%m%d%H%M'
+ value = datetime.strptime(value, fmt)
+ if field_type.startswith('date'):
+ # field_type must begin with 'date'
+ # followed by optional format 'date%Y%m%d'
+ # without format: %Y%m%d is used
+ field_type = field_type[4:]
+ fmt = field_type and field_type or '%Y%m%d'
+ value = datetime.strptime(value, fmt).date()
if field_type == 'reference' and HAS_DEXTERITY_RELATIONS:
results_referenced = pc.unrestrictedSearchResults(UID=value)
referenced_obj = results_referenced[0]._unrestrictedGetObject()


Repository: plone.app.robotframework


Branch: refs/heads/master
Date: 2017-03-09T21:38:52+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/Products.CMFPlone/commit/e25ba821c34d49a6d7b7ef10cf44440eb1e037ed
Date: 2017-03-14T16:30:08+02:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.app.robotframework/commit/fdac6b1b92948ee1108fdf1e39e22d1fd002bb50

Merge pull request #1964 from plone/fix-test-wrong-use-of-assertTrue
Merge pull request #65 from IMIO/master

Wrong use of assertTrue in testResourceRegistries
Manage datetime and date field types in "set field value" keyword

Files changed:
M CHANGES.rst
M Products/CMFPlone/resources/exportimport/resourceregistry.py
M Products/CMFPlone/tests/testResourceRegistries.py
M CONTRIBUTORS.rst
M src/plone/app/robotframework/content.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 4550eea..f378854 100644
index 6af5242..7b7124b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -36,6 +36,12 @@ Bug fixes:
This solves a problem, where Editors couldn't see inactive content, even though they had the required permission on a subpath of the portal (e.g. a subsite).
[thet]

+- Test: Wrong use of assertTrue in testResourceRegistries.
+ [jensens]
+
+- Fix issue popped iup after fix of use of assertTrue in testResourceRegistries: insert-before in legacy resource import was broken.
+ [jensens]
+
@@ -10,7 +10,8 @@ king changes:

5.1b2 (2017-02-20)
------------------
diff --git a/Products/CMFPlone/resources/exportimport/resourceregistry.py b/Products/CMFPlone/resources/exportimport/resourceregistry.py
index 6e636ed..a0343d0 100644
--- a/Products/CMFPlone/resources/exportimport/resourceregistry.py
+++ b/Products/CMFPlone/resources/exportimport/resourceregistry.py
@@ -41,7 +41,7 @@ class ResourceRegistryNodeAdapter(XMLAdapterBase):
New features:

resource_blacklist = set()
registry = None
-
+
def _importNode(self, node):
"""Import the object from the DOM node.
"""
@@ -140,12 +140,12 @@ def _importNode(self, node):
elif position[0] == 'before':
if position[1] in legacy.resources:
legacy.resources.insert(
- legacy.resources.index(position[1]) + 1,
+ legacy.resources.index(position[1]),
res_id)
else:
legacy.resources.append(res_id)
-- *add item here*
+- Manage datetime and date field types in "set field value" keyword
+ [sgeulette]

- if remove:
+ elif remove:
if res_id in legacy.resources:
legacy.resources.remove(res_id)
if res_id in resources:
diff --git a/Products/CMFPlone/tests/testResourceRegistries.py b/Products/CMFPlone/tests/testResourceRegistries.py
index 1806dc7..72c7e42 100644
--- a/Products/CMFPlone/tests/testResourceRegistries.py
+++ b/Products/CMFPlone/tests/testResourceRegistries.py
@@ -306,8 +306,10 @@ def test_insert_after(self):
""")
importer._importNode(foobar.documentElement)
resources = self._get_legacy_bundle().resources
- self.assertTrue(resources.index('one') + 1,
- resources.index('foobar-js'))
+ self.assertEqual(
+ resources.index('one') + 1,
+ resources.index('foobar-js')
+ )
Bug fixes:

def test_insert_before(self):
importer = self._get_importer()
@@ -326,8 +328,10 @@ def test_insert_before(self):
""")
importer._importNode(foobar.documentElement)
resources = self._get_legacy_bundle().resources
- self.assertTrue(resources.index('one') - 1,
- resources.index('foobar-js'))
+ self.assertEqual(
+ resources.index('one') - 1,
+ resources.index('foobar-js')
+ )
diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index f1a29c0..71b2897 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -22,6 +22,7 @@
- Roman Kozlovskyi
- Silvio Tomatis
- Steffen Lindner
+- Stephan Geulette
- Timo Stollenwerk
- Victor Fernandez de Alba
- zotya
diff --git a/src/plone/app/robotframework/content.py b/src/plone/app/robotframework/content.py
index c33e065..adde094 100644
--- a/src/plone/app/robotframework/content.py
+++ b/src/plone/app/robotframework/content.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from datetime import datetime
import os

def test_be_able_to_disable_but_not_remove(self):
importer = self._get_importer()
from Products.CMFCore.utils import getToolByName
@@ -173,6 +174,20 @@ def set_field_value(self, uid, field, value, field_type):
value = int(value)
if field_type == 'list':
value = eval(value)
+ if field_type.startswith('datetime'):
+ # field_type must begin with 'datetime'
+ # followed by optional format 'datetime%Y%m%d%H%M'
+ # without format: %Y%m%d%H%M is used
+ field_type = field_type[8:]
+ fmt = field_type and field_type or '%Y%m%d%H%M'
+ value = datetime.strptime(value, fmt)
+ if field_type.startswith('date'):
+ # field_type must begin with 'date'
+ # followed by optional format 'date%Y%m%d'
+ # without format: %Y%m%d is used
+ field_type = field_type[4:]
+ fmt = field_type and field_type or '%Y%m%d'
+ value = datetime.strptime(value, fmt).date()
if field_type == 'reference' and HAS_DEXTERITY_RELATIONS:
results_referenced = pc.unrestrictedSearchResults(UID=value)
referenced_obj = results_referenced[0]._unrestrictedGetObject()


0 comments on commit 0e9180f

Please sign in to comment.