Skip to content

Commit

Permalink
Reduce dependency on plone.app.widgets in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Apr 7, 2016
1 parent d3921b0 commit 48a37c5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -25,6 +25,9 @@ New:

Fixes:

- Reduce dependency on plone.app.widgets in tests.
[thet]

- Enhance test in order to show problem in RelatedItemsWidget with
navigation-roots
[jensens]
Expand Down
29 changes: 25 additions & 4 deletions plone/app/z3cform/tests/test_widgets.py
Expand Up @@ -4,9 +4,7 @@
from mock import Mock
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.widgets.testing import ExampleVocabulary
from plone.app.widgets.testing import PLONEAPPWIDGETS_DX_INTEGRATION_TESTING
from plone.app.widgets.testing import TestRequest
from zope.publisher.browser import TestRequest as BaseTestRequest
from plone.app.z3cform.tests.layer import PAZ3CForm_INTEGRATION_TESTING
from plone.app.z3cform.widget import BaseWidget
from plone.dexterity.fti import DexterityFTI
Expand All @@ -19,6 +17,7 @@
from zope.component import provideUtility
from zope.component.globalregistry import base
from zope.interface import alsoProvides
from zope.interface import implements
from zope.interface import Interface
from zope.schema import Choice
from zope.schema import Date
Expand All @@ -27,12 +26,34 @@
from zope.schema import Set
from zope.schema import TextLine
from zope.schema import Tuple
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

import mock
import pytz
import unittest


class ExampleVocabulary(object):
implements(IVocabularyFactory)

def __call__(self, context, query=None):
items = [u'One', u'Two', u'Three']
tmp = SimpleVocabulary([
SimpleTerm(it.lower(), it.lower(), it)
for it in items
if query is None
or query.lower() in it.lower()
])
tmp.test = 1
return tmp


class TestRequest(BaseTestRequest):
pass


class BaseWidgetTests(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -1226,7 +1247,7 @@ def _custom_field_widget(field, request):

class RichTextWidgetTests(unittest.TestCase):

layer = PLONEAPPWIDGETS_DX_INTEGRATION_TESTING
layer = PAZ3CForm_INTEGRATION_TESTING

def setUp(self):
from plone.app.textfield import RichText as RichTextField
Expand Down

1 comment on commit 48a37c5

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thet Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.app.z3cform/20/violations

plone/app/z3cform/inline_validation.py:15:1: C901 'InlineValidationView.__call__' is too complex (15)
plone/app/z3cform/tests/test_widgets.py:0:1: I001 isort found changes, run it on the file
plone/app/z3cform/tests/test_widgets.py:47:13: W503 line break before binary operator

Follow these instructions to reproduce it locally.

Please sign in to comment.