-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full coverage for the browser components.
Notably this means dropping the custom BasicAuthTransport for XMLRPC in synchronize.py because it relied on classes that don't exist in Python 3. But the built-in transports handle Basic Auth if the info is encoded in the URL, so do that instead.
- Loading branch information
Showing
10 changed files
with
370 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2017 Zope Foundation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""This module tests the Gettext Export and Import funciotnality of the | ||
Translation Domain. | ||
""" | ||
import unittest | ||
import time | ||
from io import BytesIO | ||
|
||
from zope.component.testlayer import ZCMLFileLayer | ||
|
||
from zope.app.i18n.translationdomain import TranslationDomain | ||
from zope.app.i18n.browser.exportimport import ExportImport | ||
import zope.app.i18n.tests | ||
from zope.publisher.browser import TestRequest | ||
|
||
|
||
class TestExportImport(unittest.TestCase): | ||
|
||
layer = ZCMLFileLayer(zope.app.i18n.tests) | ||
|
||
data = b''' | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Zope 3\\n" | ||
"PO-Revision-Date: %s\\n" | ||
"Last-Translator: Zope 3 Gettext Export Filter\\n" | ||
"Zope-Language: de\\n" | ||
"Zope-Domain: default\\n" | ||
"MIME-Version: 1.0\\n" | ||
"Content-Type: text/plain; charset=UTF-8\\n" | ||
"Content-Transfer-Encoding: 8bit\\n" | ||
msgid "Choose" | ||
# comment | ||
msgstr "Ausw\xc3\xa4hlen!" | ||
# comment | ||
# comment | ||
msgid "greeting" | ||
msgstr "hallo" | ||
# comment | ||
''' | ||
|
||
def setUp(self): | ||
super(TestExportImport, self).setUp() | ||
|
||
self._domain = TranslationDomain() | ||
self._domain.domain = 'default' | ||
|
||
def testImportExport(self): | ||
view = ExportImport() | ||
view.context = self._domain | ||
view.request = TestRequest() | ||
view.request.getURL = lambda _x: 'url' | ||
|
||
# Insert some extra lines and comments for the parser to skip | ||
import_data = b'\n\n'.join(self.data.split(b'\n')) | ||
|
||
view.importMessages(['de'], | ||
BytesIO(import_data % b'2002/02/02 02:02')) | ||
|
||
result = view.exportMessages('de') | ||
|
||
dt = time.time() | ||
dt = time.localtime(dt) | ||
dt = time.strftime('%Y/%m/%d %H:%M', dt) | ||
if not isinstance(dt, bytes): | ||
dt = dt.encode("utf-8") | ||
|
||
expected = self.data.replace(b'# comment\n', b'') % dt | ||
self.assertEqual(result.strip(), expected.strip()) | ||
|
||
def test_suite(): | ||
return unittest.defaultTestLoader.loadTestsFromName(__name__) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main(defaultTest=test_suite) |
Oops, something went wrong.