def test_token_input_widget_unicode(self):
        # Created to check issue 20
        # https://github.com/collective/collective.z3cform.widgets/issues/20
        from collective.z3cform.widgets.token_input_widget import\
            TokenInputWidget
        portal = self.portal
        ttool = getToolByName(self.portal, 'portal_types')
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        fti = ttool.getTypeInfo("Document")
        obj = fti.constructInstance(portal, "test1")

        class MockCatalog(object):
            def uniqueValuesFor(self, *args):
                return ["maçã"]
        
        def mock_subject():
            return ["resumé"]
        obj.portal_catalog = MockCatalog()
        obj.Subject = mock_subject

        mock_request = object()
        widget = TokenInputWidget(mock_request)
        widget.context = obj

        result = widget.js()

        self.assertTrue(isinstance(result, unicode))
        self.assertTrue(u"maçã" in result)
        self.assertTrue(u"resumé" in result)
    def test_token_input_widget_subjects(self):
        class MockCatalog(object):
            def uniqueValuesFor(self, *args):
                return ["maçã", "foo"]

        self.obj.portal_catalog = MockCatalog()
        self.obj.Subject = lambda: ["resumé", "bar"]

        widget = TokenInputWidget(self.request)
        widget.context = self.obj

        result = widget.js()

        self.assertTrue(isinstance(result, unicode))
        self.assertTrue(u"resumé" in result)
        self.assertTrue(u"bar" in result)
    def test_token_input_widget_unicode(self):
        # see: https://github.com/collective/collective.z3cform.widgets/issues/20

        class MockCatalog(object):
            def uniqueValuesFor(self, *args):
                return ["maçã"]

        self.obj.portal_catalog = MockCatalog()
        self.obj.Subject = lambda: ["resumé"]

        widget = TokenInputWidget(self.request)
        widget.context = self.obj

        result = widget.js()

        self.assertTrue(isinstance(result, unicode))
        self.assertTrue(u"resumé" in result)
Пример #4
0
    def test_token_input_widget_subjects(self):

        class MockCatalog(object):
            def uniqueValuesFor(self, *args):
                return ["maçã", "foo"]

        self.obj.portal_catalog = MockCatalog()
        self.obj.Subject = lambda: ["resumé", "bar"]

        widget = TokenInputWidget(self.request)
        widget.context = self.obj

        result = widget.js()

        self.assertTrue(isinstance(result, unicode))
        self.assertTrue(u"resumé" in result)
        self.assertTrue(u"bar" in result)
Пример #5
0
    def test_token_input_widget_unicode(self):
        # see: https://github.com/collective/collective.z3cform.widgets/issues/20

        class MockCatalog(object):
            def uniqueValuesFor(self, *args):
                return ["maçã"]

        self.obj.portal_catalog = MockCatalog()
        self.obj.Subject = lambda: ["resumé"]

        widget = TokenInputWidget(self.request)
        widget.context = self.obj

        result = widget.js()

        self.assertTrue(isinstance(result, unicode))
        self.assertTrue(u"resumé" in result)