Skip to content

Commit

Permalink
Port .browser sub-package to Python 3. (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Oct 12, 2020
1 parent cc0cd5c commit 20331fe
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changes
4.3.0 (unreleased)
------------------

- Port ``.browser`` sub-package to Python 3.

- Drop support for running the tests using ``python setup.py test``.

- Drop support for Python 3.4 and 3.5.
Expand Down
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ def read(*path):
read('CHANGES.rst')
])

tests_require = [
testing_require = [
'zope.testing >= 3.8',
'zope.testrunner',
'zope.configuration',
'BTrees',
]

tests_require = testing_require + [
# 'zope.annotation',
'zope.publisher',
]


setup(
name="zope.dublincore",
version='4.3.0.dev0',
Expand Down Expand Up @@ -84,7 +90,7 @@ def read(*path):
'zope.security[zcml]>=3.8',
],
extras_require={
'testing': tests_require,
'testing': testing_require,
'test': tests_require,
'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
},
Expand Down
7 changes: 5 additions & 2 deletions src/zope/dublincore/browser/metadataedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
_ = MessageFactory('zope')


text_type = type(u'') #PY3


class MetaDataEdit(object):
"""Provide view for editing basic dublin-core meta-data."""

Expand All @@ -33,8 +36,8 @@ def edit(self):
message=''

if 'dctitle' in request:
dc.title = unicode(request['dctitle'])
dc.description = unicode(request['dcdescription'])
dc.title = text_type(request['dctitle'])
dc.description = text_type(request['dcdescription'])
description = Attributes(IZopeDublinCore, 'title', 'description')
notify(ObjectModifiedEvent(self.context, description))
message = _("Changed data ${datetime}",
Expand Down
Empty file.
41 changes: 41 additions & 0 deletions src/zope/dublincore/browser/tests/test_metadataedit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from zope.component.testing import PlacelessSetup
from zope.dublincore.browser.metadataedit import MetaDataEdit
from zope.publisher.browser import TestRequest
import unittest
import zope.annotation.interfaces
import zope.dublincore.testing


@zope.interface.implementer(zope.annotation.interfaces.IAnnotations)
class DummyContext(dict):
"""A dummy class which can store annotations."""


class MetaDataEditTests(PlacelessSetup, unittest.TestCase):
"""Testing ..metadataedit.MetaDataEdit."""

def setUp(self):
super(MetaDataEditTests, self).setUp()
zope.dublincore.testing.setUpDublinCore()

def test_metadataedit__MetaDataEdit__edit__1(self):
"""It stores DC request values on the context."""
view = MetaDataEdit()
request = TestRequest(
form={'dctitle': 'Test', 'dcdescription': 'Testing'})
view.context = DummyContext()
view.request = request
result = view.edit()
self.assertEqual({
'message': 'Changed data ${datetime}',
'dctitle': 'Test',
'dcdescription': 'Testing',
'modified': '',
'created': '',
'creators': ()
}, result)

self.assertEqual({
'zope.app.dublincore.ZopeDublinCore': {
'Title': ('Test',),
'Description': ('Testing',)}}, view.context)
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ envlist =
commands =
zope-testrunner --test-path=src []
sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
deps =
.[test,docs]
extras =
test
docs

[testenv:coverage]
usedevelop = true
Expand All @@ -18,7 +19,6 @@ commands =
coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
coverage report
deps =
{[testenv]deps}
coverage


Expand Down

0 comments on commit 20331fe

Please sign in to comment.