diff --git a/last_commit.txt b/last_commit.txt index 106872dfbb..83bfc58824 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,372 +1,296 @@ -Repository: plone.api +Repository: plone.app.testing Branch: refs/heads/master -Date: 2016-01-29T09:07:30+01:00 -Author: Eric BREHAULT (ebrehault) -Commit: https://github.com/plone/plone.api/commit/c5ad32bc4d59f57287f0871679e20e14c59c5846 +Date: 2016-01-26T16:58:45+01:00 +Author: Johannes Raggam (thet) +Commit: https://github.com/plone/plone.app.testing/commit/47069c7c35bcfb2447ef6ee610afce753e8dbd68 -implement portal.get_default_language and portal.get_current_language +Depend on zope.testrunner and fix deprecated usage of zope.testing.testrunner. Files changed: -M docs/CHANGES.rst -M docs/portal.rst -M src/plone/api/portal.py -M src/plone/api/tests/test_portal.py - -diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst -index d6a2cc4..3d7ab97 100644 ---- a/docs/CHANGES.rst -+++ b/docs/CHANGES.rst -@@ -6,7 +6,8 @@ Changelog +M CHANGES.rst +M plone/app/testing/helpers.rst +M plone/app/testing/layers.rst +M plone/app/testing/selenium.rst +M setup.py + +diff --git a/CHANGES.rst b/CHANGES.rst +index 8b2a4e4..e12ee40 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -10,7 +10,8 @@ New: - New: + Fixes: -- *add item here* -+- Add `portal.get_default_language` and `portal.get_current_language` -+ [ebrehault] ++- Depend on ``zope.testrunner`` and fix deprecated usage of ``zope.testing.testrunner``. ++ [thet] - Fixes: -diff --git a/docs/portal.rst b/docs/portal.rst -index 499fbae..4378800 100644 ---- a/docs/portal.rst -+++ b/docs/portal.rst -@@ -125,6 +125,42 @@ To display the date/time in a user-friendly way, localized to the user's prefere - self.assertEqual(DateTime(localized).__class__, DateTime) + 5.0b6 (2015-08-22) +diff --git a/plone/app/testing/helpers.rst b/plone/app/testing/helpers.rst +index a0dc618..9ce0ca4 100644 +--- a/plone/app/testing/helpers.rst ++++ b/plone/app/testing/helpers.rst +@@ -12,7 +12,7 @@ their canonical locations at ``plone.app.testing.helpers``. + For testing, we need a testrunner -+.. _portal_get_default_language_example: -+ -+Get default language -+-------------------- -+ -+To get the default language, use :meth:`api.portal.get_default_language`. -+ -+.. code-block:: python -+ -+ from plone import api -+ lang = api.portal.get_default_language() -+ -+.. invisible-code-block: python -+ -+ # assert that the result is 'en' -+ self.assertEqual(lang, 'en') -+ -+ -+.. _portal_get_current_language_example: -+ -+Get current language -+-------------------- -+ -+To get the currently negociated language, use :meth:`api.portal.get_current_language`. -+ -+.. code-block:: python -+ -+ from plone import api -+ lang = api.portal.get_current_language() -+ -+.. invisible-code-block: python -+ -+ # assert that the result is 'en' -+ self.assertEqual(lang, 'en') -+ -+ - .. _portal_send_email_example: +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner - Send E-Mail -diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py -index 7a3133e..7b244e3 100644 ---- a/src/plone/api/portal.py -+++ b/src/plone/api/portal.py -@@ -360,3 +360,35 @@ def set_registry_record(name=None, value=None, interface=None): - get_registry_record(name) + Let's create a custom fixture layer that exercises these helpers. In this + layer, we will perform the following setup: +diff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst +index a1d238f..ba19c84 100644 +--- a/plone/app/testing/layers.rst ++++ b/plone/app/testing/layers.rst +@@ -9,7 +9,8 @@ their canonical locations at ``plone.app.testing.layers``. - registry[name] = value -+ -+ -+def get_default_language(): -+ """Return the default language. -+ -+ :returns: language identifier -+ :rtype: string -+ :Example: :ref:`portal_get_default_language_example` -+ """ -+ try: -+ from Products.CMFPlone.interfaces import ILanguageSchema -+ registry = getUtility(IRegistry) -+ settings = registry.forInterface(ILanguageSchema, prefix="plone") -+ return settings.default_language -+ except ImportError: -+ portal = get() -+ return portal.getProperty('default_language', None) -+ -+ -+def get_current_language(context=None): -+ """Return the current negociated language. -+ -+ :param context: context object -+ :type name: object -+ :returns: language identifier -+ :rtype: string -+ :Example: :ref:`portal_get_current_language_example` -+ """ -+ request = getRequest() -+ return request.get('LANGUAGE', None) or \ -+ (context and aq_inner(context).Language()) \ -+ or get_default_language() -diff --git a/src/plone/api/tests/test_portal.py b/src/plone/api/tests/test_portal.py -index 1a6aa93..ba557bd 100644 ---- a/src/plone/api/tests/test_portal.py -+++ b/src/plone/api/tests/test_portal.py -@@ -786,3 +786,13 @@ def test_set_invalid_value_on_registry_record_from_interface_msg(self): - ) - self.assertTrue(exc_str.find(" needs to be ") != -1) - self.assertTrue(exc_str.find("TextLine") != -1) -+ -+ def test_get_default_language(self): -+ """Test that default language is properly returned.""" -+ self.assertEqual(portal.get_default_language(), 'en') -+ -+ def test_get_current_language(self): -+ """Test that current language is properly returned.""" -+ self.assertEqual(portal.get_current_language(portal.get()), 'en') -+ self.layer['request']['LANGUAGE'] = 'fr' -+ self.assertEqual(portal.get_current_language(), 'fr') - - -Repository: plone.api - - -Branch: refs/heads/master -Date: 2016-01-29T14:29:08+01:00 -Author: Eric BREHAULT (ebrehault) -Commit: https://github.com/plone/plone.api/commit/29174ffdf42b25dc17cacaa668de7aeffc58e90b - -fix implementation for Plone 4 - -Files changed: -M src/plone/api/portal.py - -diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py -index 7b244e3..1910c73 100644 ---- a/src/plone/api/portal.py -+++ b/src/plone/api/portal.py -@@ -376,7 +376,8 @@ def get_default_language(): - return settings.default_language - except ImportError: - portal = get() -- return portal.getProperty('default_language', None) -+ return portal.portal_properties.site_properties.getProperty( -+ 'default_language', None) - - - def get_current_language(context=None): + For testing, we need a testrunner + +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner ++ + + Plone site fixture + ~~~~~~~~~~~~~~~~~~ +diff --git a/plone/app/testing/selenium.rst b/plone/app/testing/selenium.rst +index acc067e..f03719a 100644 +--- a/plone/app/testing/selenium.rst ++++ b/plone/app/testing/selenium.rst +@@ -44,7 +44,7 @@ and then kill the backgrouned process. + + For testing, we need a testrunner + +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner + + The ``SELENIUM_PLONE_FUNCTIONAL_TESTING`` layer instantiates the + ``FunctionalTesting`` class with two bases: ``SELENIUM_FIXTURE``, as +diff --git a/setup.py b/setup.py +index 557124b..00ccb37 100644 +--- a/setup.py ++++ b/setup.py +@@ -12,6 +12,7 @@ + 'transaction', + 'zope.interface', + 'zope.publisher', ++ 'zope.testrunner', + ] + + robot_require = ['robotsuite>=1.4.0', -Repository: plone.api +Repository: plone.app.testing Branch: refs/heads/master -Date: 2016-01-29T15:08:54+01:00 -Author: Eric BREHAULT (ebrehault) -Commit: https://github.com/plone/plone.api/commit/5dd283c538abbc3c5c606e71aaf7410341741ce9 +Date: 2016-01-26T17:12:00+01:00 +Author: Johannes Raggam (thet) +Commit: https://github.com/plone/plone.app.testing/commit/307a10e4edfe9ac652a3a310c24967c90451d08c -fix a gallicism +teardown order is different with zope.testrunner Files changed: -M docs/portal.rst +M plone/app/testing/layers.rst -diff --git a/docs/portal.rst b/docs/portal.rst -index 4378800..cae9448 100644 ---- a/docs/portal.rst -+++ b/docs/portal.rst -@@ -148,7 +148,7 @@ To get the default language, use :meth:`api.portal.get_default_language`. - Get current language - -------------------- +diff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst +index ba19c84..6913882 100644 +--- a/plone/app/testing/layers.rst ++++ b/plone/app/testing/layers.rst +@@ -367,8 +367,8 @@ When the server is torn down, the ZServer thread is stopped. + + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:ZServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. + Tear down plone.testing.z2.ZServer in ... seconds. ++ Tear down plone.app.testing.layers.PloneFixture in ... seconds. + Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. --To get the currently negociated language, use :meth:`api.portal.get_current_language`. -+To get the currently negotiated language, use :meth:`api.portal.get_current_language`. +@@ -486,8 +486,8 @@ When the server is torn down, the FTP server thread is stopped. - .. code-block:: python + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:FTPServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. + Tear down plone.testing.z2.FTPServer in ... seconds. ++ Tear down plone.app.testing.layers.PloneFixture in ... seconds. + Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. -Repository: plone.api +Repository: plone.app.testing Branch: refs/heads/master -Date: 2016-01-29T15:20:59+01:00 -Author: Eric BREHAULT (ebrehault) -Commit: https://github.com/plone/plone.api/commit/25b4fbe62845eae5544af93e9adaaa5142f14f2d +Date: 2016-01-29T15:00:27+01:00 +Author: Johannes Raggam (thet) +Commit: https://github.com/plone/plone.app.testing/commit/85d8f5c39511b72a65c9ef7418ccba98edbc6767 -improve try/except writing +Fix layers.rst doctest to be compatible with older and newer zope.testrunner layer ordering. Files changed: -M src/plone/api/portal.py - -diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py -index 1910c73..434be5d 100644 ---- a/src/plone/api/portal.py -+++ b/src/plone/api/portal.py -@@ -371,13 +371,14 @@ def get_default_language(): - """ - try: - from Products.CMFPlone.interfaces import ILanguageSchema -- registry = getUtility(IRegistry) -- settings = registry.forInterface(ILanguageSchema, prefix="plone") -- return settings.default_language - except ImportError: - portal = get() - return portal.portal_properties.site_properties.getProperty( - 'default_language', None) -+ else: -+ registry = getUtility(IRegistry) -+ settings = registry.forInterface(ILanguageSchema, prefix="plone") -+ return settings.default_language - - - def get_current_language(context=None): +M CHANGES.rst +M plone/app/testing/layers.rst + +diff --git a/CHANGES.rst b/CHANGES.rst +index e12ee40..55a98f4 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -10,6 +10,9 @@ New: + + Fixes: + ++- Fix ``layers.rst`` doctest to be compatible with older and newer zope.testrunner layer ordering. ++ [thet] ++ + - Depend on ``zope.testrunner`` and fix deprecated usage of ``zope.testing.testrunner``. + [thet] + +diff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst +index 6913882..670f7c5 100644 +--- a/plone/app/testing/layers.rst ++++ b/plone/app/testing/layers.rst +@@ -367,9 +367,8 @@ When the server is torn down, the ZServer thread is stopped. + + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:ZServer in ... seconds. +- Tear down plone.testing.z2.ZServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. +- Tear down plone.testing.z2.Startup in ... seconds. ++ ...Tear down plone.app.testing.layers.PloneFixture in ... seconds. ++ ...Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. + + >>> conn = urllib2.urlopen(portal_url + '/folder1', timeout=5) +@@ -486,9 +485,8 @@ When the server is torn down, the FTP server thread is stopped. + + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:FTPServer in ... seconds. +- Tear down plone.testing.z2.FTPServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. +- Tear down plone.testing.z2.Startup in ... seconds. ++ ...Tear down plone.app.testing.layers.PloneFixture in ... seconds. ++ ...Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. + + >>> ftpClient.connect(host, port, timeout=5) -Repository: plone.api +Repository: plone.app.testing Branch: refs/heads/master -Date: 2016-01-29T15:08:46Z -Author: Adam Forsythe-Cheasley (adamcheasley) -Commit: https://github.com/plone/plone.api/commit/3b3fd8aa8e5bee9b9b9d5232aaedebe934ca26b5 +Date: 2016-01-29T16:37:10+01:00 +Author: Johannes Raggam (thet) +Commit: https://github.com/plone/plone.app.testing/commit/bc0589f53070f07098c9dc54689aa757dcdfb80e -Merge pull request #302 from plone/ebr-get-language +Merge pull request #20 from plone/thet-zope4 -implement portal.get_default_language and portal.get_current_language +Zope4 Files changed: -M docs/CHANGES.rst -M docs/portal.rst -M src/plone/api/portal.py -M src/plone/api/tests/test_portal.py - -diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst -index 6d3b903..7526112 100644 ---- a/docs/CHANGES.rst -+++ b/docs/CHANGES.rst -@@ -6,7 +6,8 @@ Changelog +M CHANGES.rst +M plone/app/testing/helpers.rst +M plone/app/testing/layers.rst +M plone/app/testing/selenium.rst +M setup.py + +diff --git a/CHANGES.rst b/CHANGES.rst +index 8b2a4e4..55a98f4 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -10,7 +10,11 @@ New: - New: + Fixes: -- *add item here* -+- Add `portal.get_default_language` and `portal.get_current_language` -+ [ebrehault] ++- Fix ``layers.rst`` doctest to be compatible with older and newer zope.testrunner layer ordering. ++ [thet] ++ ++- Depend on ``zope.testrunner`` and fix deprecated usage of ``zope.testing.testrunner``. ++ [thet] - Fixes: -diff --git a/docs/portal.rst b/docs/portal.rst -index 499fbae..cae9448 100644 ---- a/docs/portal.rst -+++ b/docs/portal.rst -@@ -125,6 +125,42 @@ To display the date/time in a user-friendly way, localized to the user's prefere - self.assertEqual(DateTime(localized).__class__, DateTime) + 5.0b6 (2015-08-22) +diff --git a/plone/app/testing/helpers.rst b/plone/app/testing/helpers.rst +index a0dc618..9ce0ca4 100644 +--- a/plone/app/testing/helpers.rst ++++ b/plone/app/testing/helpers.rst +@@ -12,7 +12,7 @@ their canonical locations at ``plone.app.testing.helpers``. + For testing, we need a testrunner -+.. _portal_get_default_language_example: -+ -+Get default language -+-------------------- -+ -+To get the default language, use :meth:`api.portal.get_default_language`. -+ -+.. code-block:: python -+ -+ from plone import api -+ lang = api.portal.get_default_language() -+ -+.. invisible-code-block: python -+ -+ # assert that the result is 'en' -+ self.assertEqual(lang, 'en') -+ -+ -+.. _portal_get_current_language_example: -+ -+Get current language -+-------------------- -+ -+To get the currently negotiated language, use :meth:`api.portal.get_current_language`. -+ -+.. code-block:: python -+ -+ from plone import api -+ lang = api.portal.get_current_language() -+ -+.. invisible-code-block: python -+ -+ # assert that the result is 'en' -+ self.assertEqual(lang, 'en') -+ -+ - .. _portal_send_email_example: +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner - Send E-Mail -diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py -index 7a3133e..434be5d 100644 ---- a/src/plone/api/portal.py -+++ b/src/plone/api/portal.py -@@ -360,3 +360,37 @@ def set_registry_record(name=None, value=None, interface=None): - get_registry_record(name) + Let's create a custom fixture layer that exercises these helpers. In this + layer, we will perform the following setup: +diff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst +index a1d238f..670f7c5 100644 +--- a/plone/app/testing/layers.rst ++++ b/plone/app/testing/layers.rst +@@ -9,7 +9,8 @@ their canonical locations at ``plone.app.testing.layers``. - registry[name] = value -+ -+ -+def get_default_language(): -+ """Return the default language. -+ -+ :returns: language identifier -+ :rtype: string -+ :Example: :ref:`portal_get_default_language_example` -+ """ -+ try: -+ from Products.CMFPlone.interfaces import ILanguageSchema -+ except ImportError: -+ portal = get() -+ return portal.portal_properties.site_properties.getProperty( -+ 'default_language', None) -+ else: -+ registry = getUtility(IRegistry) -+ settings = registry.forInterface(ILanguageSchema, prefix="plone") -+ return settings.default_language -+ -+ -+def get_current_language(context=None): -+ """Return the current negociated language. -+ -+ :param context: context object -+ :type name: object -+ :returns: language identifier -+ :rtype: string -+ :Example: :ref:`portal_get_current_language_example` -+ """ -+ request = getRequest() -+ return request.get('LANGUAGE', None) or \ -+ (context and aq_inner(context).Language()) \ -+ or get_default_language() -diff --git a/src/plone/api/tests/test_portal.py b/src/plone/api/tests/test_portal.py -index 1a6aa93..ba557bd 100644 ---- a/src/plone/api/tests/test_portal.py -+++ b/src/plone/api/tests/test_portal.py -@@ -786,3 +786,13 @@ def test_set_invalid_value_on_registry_record_from_interface_msg(self): - ) - self.assertTrue(exc_str.find(" needs to be ") != -1) - self.assertTrue(exc_str.find("TextLine") != -1) -+ -+ def test_get_default_language(self): -+ """Test that default language is properly returned.""" -+ self.assertEqual(portal.get_default_language(), 'en') -+ -+ def test_get_current_language(self): -+ """Test that current language is properly returned.""" -+ self.assertEqual(portal.get_current_language(portal.get()), 'en') -+ self.layer['request']['LANGUAGE'] = 'fr' -+ self.assertEqual(portal.get_current_language(), 'fr') + For testing, we need a testrunner + +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner ++ + + Plone site fixture + ~~~~~~~~~~~~~~~~~~ +@@ -366,9 +367,8 @@ When the server is torn down, the ZServer thread is stopped. + + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:ZServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. +- Tear down plone.testing.z2.ZServer in ... seconds. +- Tear down plone.testing.z2.Startup in ... seconds. ++ ...Tear down plone.app.testing.layers.PloneFixture in ... seconds. ++ ...Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. + + >>> conn = urllib2.urlopen(portal_url + '/folder1', timeout=5) +@@ -485,9 +485,8 @@ When the server is torn down, the FTP server thread is stopped. + + >>> runner.tear_down_unneeded(options, [], setupLayers) + Tear down plone.app.testing.layers.Plone:FTPServer in ... seconds. +- Tear down plone.app.testing.layers.PloneFixture in ... seconds. +- Tear down plone.testing.z2.FTPServer in ... seconds. +- Tear down plone.testing.z2.Startup in ... seconds. ++ ...Tear down plone.app.testing.layers.PloneFixture in ... seconds. ++ ...Tear down plone.testing.z2.Startup in ... seconds. + Tear down plone.testing.zca.LayerCleanup in ... seconds. + + >>> ftpClient.connect(host, port, timeout=5) +diff --git a/plone/app/testing/selenium.rst b/plone/app/testing/selenium.rst +index acc067e..f03719a 100644 +--- a/plone/app/testing/selenium.rst ++++ b/plone/app/testing/selenium.rst +@@ -44,7 +44,7 @@ and then kill the backgrouned process. + + For testing, we need a testrunner + +- >>> from zope.testing.testrunner import runner ++ >>> from zope.testrunner import runner + + The ``SELENIUM_PLONE_FUNCTIONAL_TESTING`` layer instantiates the + ``FunctionalTesting`` class with two bases: ``SELENIUM_FIXTURE``, as +diff --git a/setup.py b/setup.py +index 557124b..00ccb37 100644 +--- a/setup.py ++++ b/setup.py +@@ -12,6 +12,7 @@ + 'transaction', + 'zope.interface', + 'zope.publisher', ++ 'zope.testrunner', + ] + + robot_require = ['robotsuite>=1.4.0',