示例#1
0
    def test_crackPayload_multiple_w_text(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []
        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()
        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        filepart = DummyMessage()
        filepart.filename = 'file1.bin'
        filepart.payload = '0123456789ABCDEF'
        filepart.content_type = 'application/octet-stream'
        textpart = DummyMessage()
        textpart.payload = 'payload'
        textpart.charset = 'rot13'
        textpart.content_type = 'text/plain'
        message.payload = (filepart, textpart)

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'CNLYBNQ')
        self.assertEqual(len(attachments), 1)
        filename, mimetype, data = attachments[0]
        self.assertEqual(filename, 'file1.bin')
        self.assertEqual(mimetype, 'application/octet-stream')
        self.assertEqual(data, '0123456789ABCDEF')
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'cnlybnq')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], False)
示例#2
0
    def test_handle_submit_new_to_karl(self):
        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IInvitation
        from karl.utilities.interfaces import IRandomId
        request = testing.DummyRequest()
        context = self._makeCommunity()
        mailer = self._registerMailer()
        registerCatalogSearch()

        def nonrandom(size=6):
            return 'A' * size

        karltesting.registerUtility(nonrandom, IRandomId)
        registerContentFactory(DummyInvitation, IInvitation)
        controller = self._makeOne(context, request)
        converted = {
            'email_addresses': [u'*****@*****.**'],
            'text': u'some text',
        }

        karltesting.registerDummyRenderer(
            'karl.views:templates/email_invite_new.pt')
        response = controller.handle_submit(converted)
        self.assertEqual(
            response.location,
            'http://example.com/manage.html?status_message=One+user+invited.++'
        )
        invitation = context['A' * 6]
        self.assertEqual(invitation.email, '*****@*****.**')
        self.assertEqual(1, len(mailer))
        self.assertEqual(mailer[0].mto, [
            u"*****@*****.**",
        ])
示例#3
0
    def test_submit_form(self):
        from repoze.sendmail.interfaces import IMailDelivery
        karltesting.registerDummyRenderer("templates/join_community.pt")

        c = karltesting.DummyCommunity()
        c.moderator_names = set(["moderator1", "moderator2"])
        site = c.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        profiles["user"] = karltesting.DummyProfile()
        profiles["moderator1"] = karltesting.DummyProfile()
        profiles["moderator2"] = karltesting.DummyProfile()

        mailer = karltesting.DummyMailer()
        karltesting.registerUtility(mailer, IMailDelivery)

        karltesting.registerDummySecurityPolicy("user")
        request = testing.DummyRequest({
            "form.submitted": "1",
            "message": "Message text.",
        })
        karltesting.registerDummyRenderer(
            'karl.views:templates/email_join_community.pt')
        response = self._callFUT(c, request)

        self.assertEqual(response.location,
                         "http://example.com/communities/community/"
                         "?status_message=Your+request+has+been+sent+"
                         "to+the+moderators.")
        self.assertEqual(len(mailer), 1)
        msg = mailer.pop()
        self.assertEqual(msg.mto, ["*****@*****.**",
                                   "*****@*****.**"])
    def test_handle_submit_new_to_karl(self):
        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IInvitation
        from karl.utilities.interfaces import IRandomId
        request = testing.DummyRequest()
        context = self._makeCommunity()
        mailer = self._registerMailer()
        registerCatalogSearch()
        def nonrandom(size=6):
            return 'A' * size
        karltesting.registerUtility(nonrandom, IRandomId)
        registerContentFactory(DummyInvitation, IInvitation)
        controller = self._makeOne(context, request)
        converted = {
            'email_addresses': [u'*****@*****.**'],
            'text': u'some text',
            }

        karltesting.registerDummyRenderer(
            'karl.views:templates/email_invite_new.pt')
        response = controller.handle_submit(converted)
        self.assertEqual(response.location,
          'http://example.com/manage.html?status_message=One+user+invited.++'
                         )
        invitation = context['A'*6]
        self.assertEqual(invitation.email, '*****@*****.**')
        self.assertEqual(1, len(mailer))
        self.assertEqual(mailer[0].mto, [u"*****@*****.**",])
示例#5
0
    def test_handle_submit_inactive_user(self):
        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IInvitation
        from karl.utilities.interfaces import IRandomId
        request = testing.DummyRequest()
        context = self._makeCommunity()
        self._registerMailer()
        registerCatalogSearch()
        profile = karltesting.DummyProfile(security_state='inactive')
        profile.__name__ = 'd'
        registerCatalogSearch(results={'[email protected]': [
            profile,
        ]})

        def nonrandom(size=6):
            return 'A' * size

        karltesting.registerUtility(nonrandom, IRandomId)
        registerContentFactory(DummyInvitation, IInvitation)
        controller = self._makeOne(context, request)
        converted = {
            'email_addresses': [u'*****@*****.**'],
            'text': u'some text',
        }
        karltesting.registerDummyRenderer(
            'karl.views:templates/email_add_existing.pt')
        from pyramid_formish import ValidationError
        self.assertRaises(ValidationError, controller.handle_submit, converted)
示例#6
0
    def test_known_kind_no_text_term(self):
        from webob.multidict import MultiDict
        from karl.models.interfaces import IGroupSearchFactory
        from repoze.lemonade.testing import registerContentFactory
        from zope.interface import Interface

        content = DummyCommunityContent()

        def search_factory(*arg, **kw):
            return DummySearchFactory(content)

        search_factory.icon = "foo.jpg"
        search_factory.advanced_search = True
        karltesting.registerUtility(search_factory, IGroupSearchFactory, name="People")
        context = testing.DummyModel()
        context.catalog = {}
        context["profiles"] = profiles = testing.DummyModel()
        profiles["tweedle dee"] = testing.DummyModel(title="Tweedle Dee")
        request = testing.DummyRequest(params=MultiDict({"kind": "People"}))
        request.layout_manager = mock.Mock()
        from karl.models.interfaces import ICatalogSearch
        from karl.views.interfaces import IAdvancedSearchResultsDisplay

        registerContentFactory(DummyContent, IDummyContent)
        karltesting.registerAdapter(DummySearch, (Interface), ICatalogSearch)
        karltesting.registerAdapter(DummySearchResultsDisplay, (Interface, Interface), IAdvancedSearchResultsDisplay)
        result = self._callFUT(context, request)
        self.assertEqual(result["terms"], ["People"])
        self.assertEqual(len(result["results"]), 1)
 def test_handle_submit_already_in_community(self):
     from repoze.lemonade.testing import registerContentFactory
     from karl.models.interfaces import IInvitation
     from karl.utilities.interfaces import IRandomId
     request = testing.DummyRequest()
     context = self._makeCommunity()
     mailer = self._registerMailer()
     registerCatalogSearch()
     profile = karltesting.DummyProfile()
     profile.__name__ = 'a'
     registerCatalogSearch(results={'[email protected]': [profile,]})
     def nonrandom(size=6):
         return 'A' * size
     karltesting.registerUtility(nonrandom, IRandomId)
     registerContentFactory(DummyInvitation, IInvitation)
     controller = self._makeOne(context, request)
     converted = {
         'email_addresses': [u'*****@*****.**'],
         'text': u'some text',
         }
     response = controller.handle_submit(converted)
     self.assertEqual(response.location,
       'http://example.com/manage.html?status_message=One+user+already+member.'
                      )
     self.failIf('A'*6 in context)
     self.assertEqual(context.users.added_groups, [])
示例#8
0
    def test_known_kind_no_text_term(self):
        from webob.multidict import MultiDict
        from karl.models.interfaces import IGroupSearchFactory
        from repoze.lemonade.testing import registerContentFactory
        from zope.interface import Interface
        content = DummyCommunityContent()

        def search_factory(*arg, **kw):
            return DummySearchFactory(content)

        search_factory.icon = 'foo.jpg'
        search_factory.advanced_search = True
        karltesting.registerUtility(search_factory,
                                    IGroupSearchFactory,
                                    name='People')
        context = testing.DummyModel()
        context.catalog = {}
        context['profiles'] = profiles = testing.DummyModel()
        profiles['tweedle dee'] = testing.DummyModel(title='Tweedle Dee')
        request = testing.DummyRequest(params=MultiDict({'kind': 'People'}))
        request.layout_manager = mock.Mock()
        from karl.models.interfaces import ICatalogSearch
        from karl.views.interfaces import IAdvancedSearchResultsDisplay
        registerContentFactory(DummyContent, IDummyContent)
        karltesting.registerAdapter(DummySearch, (Interface), ICatalogSearch)
        karltesting.registerAdapter(DummySearchResultsDisplay,
                                    (Interface, Interface),
                                    IAdvancedSearchResultsDisplay)
        result = self._callFUT(context, request)
        self.assertEqual(result['terms'], ['People'])
        self.assertEqual(len(result['results']), 1)
示例#9
0
    def test_crackPayload_single_with_scrubber_is_reply(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []

        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()

        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        message.payload = 'payload'
        message.content_type = 'text/plain'
        setattr(message, 'in-reply-to', 'foo')

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'PAYLOAD')
        self.assertEqual(len(attachments), 0)
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'payload')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], True)
示例#10
0
 def test_known_kind_no_text_term(self):
     from webob.multidict import MultiDict
     from karl.models.interfaces import IGroupSearchFactory
     from repoze.lemonade.testing import registerContentFactory
     from zope.interface import Interface
     content = DummyCommunityContent()
     def search_factory(*arg, **kw):
         return DummySearchFactory(content)
     search_factory.icon = 'foo.jpg'
     search_factory.advanced_search = True
     karltesting.registerUtility(
         search_factory, IGroupSearchFactory, name='People')
     context = testing.DummyModel()
     context.catalog = {}
     context['profiles'] = profiles = testing.DummyModel()
     profiles['tweedle dee'] = testing.DummyModel(title='Tweedle Dee')
     request = testing.DummyRequest(
         params=MultiDict({'kind':'People'}))
     from karl.models.interfaces import ICatalogSearch
     from karl.views.interfaces import IAdvancedSearchResultsDisplay
     registerContentFactory(DummyContent, IDummyContent)
     karltesting.registerAdapter(DummySearch, (Interface),
                             ICatalogSearch)
     karltesting.registerAdapter(DummySearchResultsDisplay,
                             (Interface, Interface),
                             IAdvancedSearchResultsDisplay)
     result = self._callFUT(context, request)
     self.assertEqual(result['terms'], ['People'])
     self.assertEqual(len(result['results']), 1)
示例#11
0
    def test_handle_submit_already_in_community(self):
        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IInvitation
        from karl.utilities.interfaces import IRandomId
        request = testing.DummyRequest()
        context = self._makeCommunity()
        self._registerMailer()
        registerCatalogSearch()
        profile = karltesting.DummyProfile()
        profile.__name__ = 'a'
        registerCatalogSearch(results={'[email protected]': [
            profile,
        ]})

        def nonrandom(size=6):
            return 'A' * size

        karltesting.registerUtility(nonrandom, IRandomId)
        registerContentFactory(DummyInvitation, IInvitation)
        controller = self._makeOne(context, request)
        converted = {
            'email_addresses': [u'*****@*****.**'],
            'text': u'some text',
        }
        response = controller.handle_submit(converted)
        self.assertEqual(
            response.location,
            'http://example.com/manage.html?status_message=One+user+already+member.'
        )
        self.failIf('A' * 6 in context)
        self.assertEqual(context.users.added_groups, [])
示例#12
0
    def test_getMessageTarget_report_alias_w_subdomain(self):
        from pyramid.interfaces import ISettings
        from pyramid.traversal import resource_path
        from zope.interface import directlyProvides
        from karl.models.interfaces import IPeopleDirectory
        from karl.testing import registerUtility
        settings = dict(system_list_subdomain='lists.example.com')
        registerUtility(settings, ISettings)
        context = self._makeRoot()
        cf = context['communities'] = self._makeContext()
        cf['testing'] = self._makeContext()
        pd = context['people'] = self._makeContext()
        directlyProvides(pd, IPeopleDirectory)
        section = pd['section'] = self._makeContext()
        extant = section['extant'] = self._makeContext()
        context.list_aliases['testing'] = resource_path(extant)
        mailin = self._makeOne(context)
        message = DummyMessage()
        message.to = ('*****@*****.**', )

        info = mailin.getMessageTargets(message)

        self.failIf(info.get('error'), info)
        targets = info['targets']
        self.assertEqual(len(targets), 1)
        info = targets[0]
        self.assertEqual(info['report'], 'section+extant')
        self.assertEqual(info['community'], None)
        self.assertEqual(info['tool'], None)
        self.failIf(info.get('in_reply_to'), info)
示例#13
0
    def test_handle_submit_already_in_karl(self):
        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IInvitation
        from karl.utilities.interfaces import IRandomId
        request = testing.DummyRequest()
        context = self._makeCommunity()
        self._registerMailer()
        registerCatalogSearch()
        profile = karltesting.DummyProfile(security_state='active')
        profile.__name__ = 'd'
        registerCatalogSearch(results={'[email protected]': [
            profile,
        ]})

        def nonrandom(size=6):
            return 'A' * size

        karltesting.registerUtility(nonrandom, IRandomId)
        registerContentFactory(DummyInvitation, IInvitation)
        controller = self._makeOne(context, request)
        converted = {
            'email_addresses': [u'*****@*****.**'],
            'text': u'some text',
        }
        karltesting.registerDummyRenderer(
            'karl.views:templates/email_add_existing.pt')
        response = controller.handle_submit(converted)
        self.assertEqual(
            response.location,
            'http://example.com/manage.html?status_message=One+existing+Karl+user+added+to+community.++'
        )
        self.failIf('A' * 6 in context)
        self.assertEqual(context.users.added_groups,
                         [('d', 'group:community:members')])
示例#14
0
    def test_crackPayload_multiple_w_text(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []

        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()

        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        filepart = DummyMessage()
        filepart.filename = 'file1.bin'
        filepart.payload = '0123456789ABCDEF'
        filepart.content_type = 'application/octet-stream'
        textpart = DummyMessage()
        textpart.payload = 'payload'
        textpart.charset = 'rot13'
        textpart.content_type = 'text/plain'
        message.payload = (filepart, textpart)

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'CNLYBNQ')
        self.assertEqual(len(attachments), 1)
        filename, mimetype, data = attachments[0]
        self.assertEqual(filename, 'file1.bin')
        self.assertEqual(mimetype, 'application/octet-stream')
        self.assertEqual(data, '0123456789ABCDEF')
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'cnlybnq')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], False)
 def test_handle_submit_already_in_karl(self):
     from repoze.lemonade.testing import registerContentFactory
     from karl.models.interfaces import IInvitation
     from karl.utilities.interfaces import IRandomId
     request = testing.DummyRequest()
     context = self._makeCommunity()
     mailer = self._registerMailer()
     registerCatalogSearch()
     profile = karltesting.DummyProfile(security_state='active')
     profile.__name__ = 'd'
     registerCatalogSearch(results={'[email protected]': [profile,]})
     def nonrandom(size=6):
         return 'A' * size
     karltesting.registerUtility(nonrandom, IRandomId)
     registerContentFactory(DummyInvitation, IInvitation)
     controller = self._makeOne(context, request)
     converted = {
         'email_addresses': [u'*****@*****.**'],
         'text': u'some text',
         }
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     response = controller.handle_submit(converted)
     self.assertEqual(response.location,
       'http://example.com/manage.html?status_message=One+existing+Karl+user+added+to+community.++'
                      )
     self.failIf('A'*6 in context)
     self.assertEqual(context.users.added_groups,
                      [('d', 'group:community:members')])
示例#16
0
    def test_submit_form(self):
        from repoze.sendmail.interfaces import IMailDelivery
        karltesting.registerDummyRenderer("templates/join_community.pt")

        c = karltesting.DummyCommunity()
        c.moderator_names = set(["moderator1", "moderator2"])
        site = c.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        profiles["user"] = karltesting.DummyProfile()
        profiles["moderator1"] = karltesting.DummyProfile()
        profiles["moderator2"] = karltesting.DummyProfile()

        mailer = karltesting.DummyMailer()
        karltesting.registerUtility(mailer, IMailDelivery)

        karltesting.registerDummySecurityPolicy("user")
        request = testing.DummyRequest({
            "form.submitted": "1",
            "message": "Message text.",
        })
        karltesting.registerDummyRenderer(
            'karl.views:templates/email_join_community.pt')
        response = self._callFUT(c, request)

        self.assertEqual(response.location,
                         "http://example.com/communities/community/"
                         "?status_message=Your+request+has+been+sent+"
                         "to+the+moderators.")
        self.assertEqual(len(mailer), 1)
        msg = mailer.pop()
        self.assertEqual(msg.mto, ["*****@*****.**",
                                   "*****@*****.**"])
示例#17
0
    def test_getMessageTarget_report_alias_w_subdomain(self):
        from pyramid.interfaces import ISettings
        from pyramid.traversal import resource_path
        from zope.interface import directlyProvides
        from karl.models.interfaces import IPeopleDirectory
        from karl.testing import registerUtility
        settings = dict(system_list_subdomain = 'lists.example.com')
        registerUtility(settings, ISettings)
        context = self._makeRoot()
        cf = context['communities'] = self._makeContext()
        cf['testing'] = self._makeContext()
        pd = context['people'] = self._makeContext()
        directlyProvides(pd, IPeopleDirectory)
        section = pd['section'] = self._makeContext()
        extant = section['extant'] = self._makeContext()
        context.list_aliases['testing'] = resource_path(extant)
        mailin = self._makeOne(context)
        message = DummyMessage()
        message.to = ('*****@*****.**',)

        info = mailin.getMessageTargets(message)

        self.failIf(info.get('error'), info)
        targets = info['targets']
        self.assertEqual(len(targets), 1)
        info = targets[0]
        self.assertEqual(info['report'], 'section+extant')
        self.assertEqual(info['community'], None)
        self.assertEqual(info['tool'], None)
        self.failIf(info.get('in_reply_to'), info)
示例#18
0
    def _registerAlerts(self):
        from karl.utilities.interfaces import IAlerts
        from karl.testing import registerUtility

        alerts = DummyAlerts()
        registerUtility(alerts, IAlerts)
        return alerts
示例#19
0
文件: test_api.py 项目: araymund/karl
 def test_custom_logo_url(self):
     context = testing.DummyModel()
     request = testing.DummyRequest()
     from pyramid.interfaces import ISettings
     settings = {'logo_path':'mylogo.png'}
     karltesting.registerUtility(settings, ISettings)
     api = self._makeOne(context, request)
     self.assertEqual(api.logo_url, api.static_url + '/mylogo.png')
示例#20
0
 def test_custom_logo_url(self):
     context = testing.DummyModel()
     request = testing.DummyRequest()
     from pyramid.interfaces import ISettings
     settings = {'logo_path': 'mylogo.png'}
     karltesting.registerUtility(settings, ISettings)
     api = self._makeOne(context, request)
     self.assertEqual(api.logo_url, api.static_url + '/mylogo.png')
示例#21
0
 def _register(self):
     from zope.interface import Interface
     from karl.models.interfaces import ITagQuery
     from pyramid_formish import IFormishRenderer
     karltesting.registerAdapter(DummyTagQuery, (Interface, Interface),
                                 ITagQuery)
     def renderer(template, args):
         return ''
     karltesting.registerUtility(renderer, IFormishRenderer)
示例#22
0
 def test_mimeinfo_with_mimetype(self):
     def m(mimetype):
         return 123
     from karl.utilities.interfaces import IMimeInfo
     karltesting.registerUtility(m, IMimeInfo)
     context = testing.DummyModel(mimetype='abc')
     request = testing.DummyRequest()
     adapter = self._makeOne(context, request)
     self.assertEqual(adapter.mimeinfo, 123)
示例#23
0
 def _register(self):
     from zope.interface import Interface
     from karl.models.interfaces import ITagQuery
     from pyramid_formish import IFormishRenderer
     karltesting.registerAdapter(DummyTagQuery, (Interface, Interface),
                                 ITagQuery)
     def renderer(template, args):
         return ''
     karltesting.registerUtility(renderer, IFormishRenderer)
 def test_handle_submit_success(self):
     from karl.models.interfaces import IProfile
     from repoze.lemonade.testing import registerContentFactory
     from repoze.sendmail.interfaces import IMailDelivery
     from repoze.workflow.testing import registerDummyWorkflow
     from karl.models.interfaces import ICommunity
     from zope.interface import directlyProvides
     workflow = registerDummyWorkflow('security')
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     registerContentFactory(DummyContent, IProfile)
     class DummyWhoPlugin(object):
         def remember(self, environ, identity):
             self.identity = identity
             return []
     request = self._makeRequest()
     community = testing.DummyModel()
     profiles = testing.DummyModel()
     community['profiles'] = profiles
     community.users = karltesting.DummyUsers()
     community.members_group_name = 'community:members'
     directlyProvides(community, ICommunity)
     context = self._makeContext()
     community['invite'] = context
     community.title = 'Community'
     community.description = 'Community'
     community.sessions = DummySessions()
     context.email = '*****@*****.**'
     controller = self._makeOne(context, request)
     converted = {'password':'******', 'password_confirm':'1',
                  'username':'******',
                  'firstname':'firstname', 'lastname':'lastname',
                  'phone':'phone', 'extension':'extension',
                  'department':'department', 'position':'position',
                  'organization':'organization', 'location':'location',
                  'country':'country', 'websites':['website'],
                  'languages':'languages', 'date_format':'en-US',
                  'biography':'bio',
                  }
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_accept_invitation.pt')
     response = controller.handle_submit(converted)
     self.assertEqual(response.location,
                      'http://example.com/?status_message=Welcome%21')
     self.assertEqual(community.users.added,
                      ('username', 'username', '1', ['community:members']))
     profiles = community['profiles']
     self.failUnless('username' in profiles)
     self.assertEqual(workflow.initialized,[profiles['username']])
     profile = profiles['username']
     self.assertEqual('phone', profile.phone)
     self.assertEqual('firstname', profile.firstname)
     self.assertEqual('lastname', profile.lastname)
     self.assertEqual('bio', profile.biography)
     self.failIf('invite' in community)
     self.assertEqual(len(mailer), 1)
示例#25
0
 def test_mimeinfo_with_mimetype(self):
     mimeinfo = {'small_icon_name': 'iddybiddy.png'}
     def m(mimetype):
         return mimeinfo
     from karl.utilities.interfaces import IMimeInfo
     karltesting.registerUtility(m, IMimeInfo)
     context = testing.DummyModel(mimetype='abc')
     request = testing.DummyRequest()
     adapter = self._makeOne(context, request)
     self.assertEqual(adapter.mimeinfo, mimeinfo)
示例#26
0
 def test_posted_date(self):
     from karl.utilities.interfaces import IKarlDates
     context = DummyContext()
     d1 = 'Wednesday, January 28, 2009 08:32 AM'
     def dummy(date, flavor):
         return d1
     karltesting.registerUtility(dummy, IKarlDates)
     request = testing.DummyRequest()
     adapter = self._makeOne(context, request)
     self.assertEqual(adapter.posted_date, context.posted_date)
示例#27
0
 def _registerMailDelivery(self):
     from repoze.sendmail.interfaces import IMailDelivery
     class DummyMailDelivery:
         def __init__(self):
             self._sent = []
         def send(self, to, message):
             self._sent.append((to, message))
     md = DummyMailDelivery()
     karltesting.registerUtility(md, IMailDelivery)
     return md
示例#28
0
 def test___call___app_url_trailing_slash(self):
     from pyramid.interfaces import ISettings
     from pyramid.testing import DummyModel
     from karl.testing import registerUtility
     settings = dict(offline_app_url = "http://offline.example.com/app/")
     registerUtility(settings, ISettings)
     parent = DummyModel()
     context = parent['foo'] = DummyModel()
     url = self._makeOne(context)
     self.assertEqual(url(), 'http://offline.example.com/app/foo')
示例#29
0
 def setUp(self):
     testing.cleanUp()
     import os
     from pyramid.interfaces import ISettings
     from karl.views.tests import test_admin
     # get the dir for existing test file for admin views
     test_dir = os.path.abspath(os.path.dirname(test_admin.__file__))
     settings = karltesting.DummySettings(
         statistics_folder=test_dir,
     )
     karltesting.registerUtility(settings, ISettings)
示例#30
0
    def test_mimeinfo_with_mimetype(self):
        mimeinfo = {'small_icon_name': 'iddybiddy.png'}

        def m(mimetype):
            return mimeinfo

        from karl.utilities.interfaces import IMimeInfo
        karltesting.registerUtility(m, IMimeInfo)
        context = testing.DummyModel(mimetype='abc')
        request = testing.DummyRequest()
        adapter = self._makeOne(context, request)
        self.assertEqual(adapter.mimeinfo, mimeinfo)
示例#31
0
 def test_posted_date_compact(self):
     from karl.utilities.interfaces import IKarlDates
     context = DummyContext()
     request = testing.DummyRequest()
     dummy = mock.Mock(return_value=mock.sentinel.SOMEDATE)
     karltesting.registerUtility(dummy, IKarlDates)
     adapter = self._makeOne(context, request)
     self.assertEqual(adapter.posted_date_compact, mock.sentinel.SOMEDATE)
     dummy.assert_called_once_with(
         datetime(2009, 1, 28, 13, 32, 0, 928857),
         'compact',
     )
示例#32
0
 def test_posted_date_compact(self):
     from karl.utilities.interfaces import IKarlDates
     context = DummyContext()
     request = testing.DummyRequest()
     dummy = mock.Mock(return_value=mock.sentinel.SOMEDATE)
     karltesting.registerUtility(dummy, IKarlDates)
     adapter = self._makeOne(context, request)
     self.assertEqual(adapter.posted_date_compact, mock.sentinel.SOMEDATE)
     dummy.assert_called_once_with(
         datetime(2009, 1, 28, 13, 32, 0, 928857),
         'compact',
         )
示例#33
0
    def test_it_inform_moderators(self):
        from pyramid.interfaces import ISettings
        karltesting.registerUtility(karltesting.DummySettings(), ISettings)

        site = karltesting.DummyModel()
        site['fred'] = profile = karltesting.DummyProfile()
        profile.title = 'Fred Flintstone'
        profile.email = '*****@*****.**'
        site['clint'] = moderator = karltesting.DummyProfile()
        moderator.title = 'Clint'
        moderator.email = '*****@*****.**'

        site.users = karltesting.DummyUsers()
        site.users.add('fred', 'fred', 'password', set(
            ('group.community:Test1:members',
             'group.community:Test2:members',
             'group.community:Test2:moderators',
             'group.SomeGroup')))
        site.users.add('clint', 'clint', 'password', set(
            ('group.community:Test1:moderators',
             'group.community:Test2:moderators')))

        site['communities'] = communities = karltesting.DummyModel()
        communities['Test1'] = karltesting.DummyModel(title='Test One')
        communities['Test2'] = karltesting.DummyModel(title='Test Two')

        mailer = karltesting.registerDummyMailer()
        renderer = karltesting.registerDummyRenderer(
            'templates/email_notify_former_staff.pt'
        )

        self._call_fut(profile)

        removed = site.users.removed_groups
        self.failIf(('fred', 'group.SomeGroup') in removed)
        self.failUnless(('fred', 'group.community:Test1:members') in removed)
        self.failUnless(('fred', 'group.community:Test2:moderators')
                        in removed)

        self.assertEqual(len(mailer), 1, mailer)
        sent = mailer[0]
        self.assertEqual(sent.mto, ['Clint <*****@*****.**>'])
        self.assertEqual(renderer.name, 'Fred Flintstone')
        self.assertEqual(renderer.communities, [
            {'unremove_url': 'http://offline.example.com/app/communities/Test1'
                             '/members/add_existing.html?user_id=fred',
             'title': 'Test One'},
            {'unremove_url': 'http://offline.example.com/app/communities/Test2'
                             '/members/add_existing.html?user_id=fred',
             'title': 'Test Two'}]
        )
示例#34
0
 def test___call__with_userid_get(self):
     from repoze.sendmail.interfaces import IMailDelivery
     request = testing.DummyRequest({"user_id": "admin"})
     context = self._getContext()
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     controller = self._makeOne(context, request)
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     response = controller()
     self.assertEqual(context.users.added_groups, [('admin','members')])
     self.assertEqual(mailer[0].mto[0], '*****@*****.**')
     self.failUnless(
         response.location.startswith('http://example.com/manage.html'))
示例#35
0
 def test___call__with_userid_get(self):
     from repoze.sendmail.interfaces import IMailDelivery
     request = testing.DummyRequest({"user_id": "admin"})
     context = self._getContext()
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     controller = self._makeOne(context, request)
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     response = controller()
     self.assertEqual(context.users.added_groups, [('admin', 'members')])
     self.assertEqual(mailer[0].mto[0], '*****@*****.**')
     self.failUnless(
         response.location.startswith('http://example.com/manage.html'))
示例#36
0
 def test_handle_submit_success(self):
     from repoze.sendmail.interfaces import IMailDelivery
     request = testing.DummyRequest()
     context = self._getContext()
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     controller = self._makeOne(context, request)
     converted = {'users': (u'admin', ), 'text': 'some_text'}
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     response = controller.handle_submit(converted)
     self.assertEqual(context.users.added_groups, [('admin', 'members')])
     self.assertEqual(mailer[0].mto[0], '*****@*****.**')
     self.failUnless(
         response.location.startswith('http://example.com/manage.html'))
 def test_handle_submit_success(self):
     from repoze.sendmail.interfaces import IMailDelivery
     request = testing.DummyRequest()
     context = self._getContext()
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     controller = self._makeOne(context, request)
     converted = {'users': (u'admin',), 'text':'some_text'}
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     response = controller.handle_submit(converted)
     self.assertEqual(context.users.added_groups, [('admin','members')])
     self.assertEqual(mailer[0].mto[0], '*****@*****.**')
     self.failUnless(
         response.location.startswith('http://example.com/manage.html'))
示例#38
0
    def test_crackPayload_w_forwarded_message(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []

        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()

        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        filepart = DummyMessage()
        filepart.filename = 'file1.bin'
        filepart.payload = '0123456789ABCDEF'
        filepart.content_type = 'application/octet-stream'
        forwarded = DummyMessage()
        forwarded.payload = None
        forwarded.filename = "Re: prune script testing."
        forwarded.content_type = 'message/rfc822; name="Re: prune script..."'
        textpart = DummyMessage()
        textpart.payload = 'payload'
        textpart.charset = 'rot13'
        textpart.content_type = 'text/plain'
        textpart2 = DummyMessage()
        textpart2.payload = 'howdy folks.\n'
        textpart2.charset = 'ascii'
        textpart2.content_type = 'text/plain'
        message.payload = (textpart, forwarded, filepart, textpart2)

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'CNLYBNQ\n\nHOWDY FOLKS.\n')
        self.assertEqual(len(attachments), 1)
        filename, mimetype, data = attachments[0]
        self.assertEqual(filename, 'file1.bin')
        self.assertEqual(mimetype, 'application/octet-stream')
        self.assertEqual(data, '0123456789ABCDEF')
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'cnlybnq\n\nhowdy folks.\n')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], False)
示例#39
0
 def test_unfound_model(self):
     from pyramid.interfaces import IDebugLogger
     class DummyLogger:
         def warn(self, msg):
             self.msg = msg
     logger = DummyLogger()
     karltesting.registerUtility(logger, IDebugLogger)
     a = testing.DummyModel()
     b = testing.DummyModel()
     karltesting.registerModels({'/a':a})
     context = testing.DummyModel()
     context.catalog = karltesting.DummyCatalog({1:'/a', 2:'/b'})
     adapter = self._makeOne(context)
     num, docids, resolver = adapter()
     self.assertEqual(num, 2)
     self.assertEqual(list(docids), [1, 2])
     results = filter(None, map(resolver, docids))
     self.assertEqual(results, [a])
     self.assertEqual(logger.msg, 'Model missing: /b')
示例#40
0
    def test_crackPayload_w_forwarded_message(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []
        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()
        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        filepart = DummyMessage()
        filepart.filename = 'file1.bin'
        filepart.payload = '0123456789ABCDEF'
        filepart.content_type = 'application/octet-stream'
        forwarded = DummyMessage()
        forwarded.payload = None
        forwarded.filename = "Re: prune script testing."
        forwarded.content_type = 'message/rfc822; name="Re: prune script..."'
        textpart = DummyMessage()
        textpart.payload = 'payload'
        textpart.charset = 'rot13'
        textpart.content_type = 'text/plain'
        textpart2 = DummyMessage()
        textpart2.payload = 'howdy folks.\n'
        textpart2.charset = 'ascii'
        textpart2.content_type = 'text/plain'
        message.payload = (textpart, forwarded, filepart, textpart2)

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'CNLYBNQ\n\nHOWDY FOLKS.\n')
        self.assertEqual(len(attachments), 1)
        filename, mimetype, data = attachments[0]
        self.assertEqual(filename, 'file1.bin')
        self.assertEqual(mimetype, 'application/octet-stream')
        self.assertEqual(data, '0123456789ABCDEF')
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'cnlybnq\n\nhowdy folks.\n')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], False)
示例#41
0
    def test_crackPayload_single_with_scrubber(self):
        from karl.testing import registerUtility
        from karl.utilities.interfaces import IMailinTextScrubber
        _called_with = []
        def _fooScrubber(text, text_mimetype=None, is_reply=False):
            _called_with.append((text, text_mimetype, is_reply))
            return text.upper()
        registerUtility(_fooScrubber, IMailinTextScrubber, 'foo')
        mailin = self._makeOne()
        mailin.text_scrubber = 'foo'
        message = DummyMessage()
        message.payload = 'payload'
        message.content_type = 'text/plain'

        text, attachments = mailin.crackPayload(message)

        self.assertEqual(text, u'PAYLOAD')
        self.assertEqual(len(attachments), 0)
        self.assertEqual(len(_called_with), 1)
        self.assertEqual(_called_with[0][0], 'payload')
        self.assertEqual(_called_with[0][1], 'text/plain')
        self.assertEqual(_called_with[0][2], False)
 def test_handle_submit_inactive_user(self):
     from repoze.lemonade.testing import registerContentFactory
     from karl.models.interfaces import IInvitation
     from karl.utilities.interfaces import IRandomId
     request = testing.DummyRequest()
     context = self._makeCommunity()
     mailer = self._registerMailer()
     registerCatalogSearch()
     profile = karltesting.DummyProfile(security_state='inactive')
     profile.__name__ = 'd'
     registerCatalogSearch(results={'[email protected]': [profile,]})
     def nonrandom(size=6):
         return 'A' * size
     karltesting.registerUtility(nonrandom, IRandomId)
     registerContentFactory(DummyInvitation, IInvitation)
     controller = self._makeOne(context, request)
     converted = {
         'email_addresses': [u'*****@*****.**'],
         'text': u'some text',
         }
     karltesting.registerDummyRenderer(
         'karl.views:templates/email_add_existing.pt')
     from pyramid_formish import ValidationError
     self.assertRaises(ValidationError, controller.handle_submit, converted)
示例#43
0
 def setUp(self):
     testing.cleanUp()
     karltesting.registerUtility(DummySpellChecker, iface=ISpellChecker)
示例#44
0
 def setUp(self):
     testing.cleanUp()
     karltesting.registerUtility(DummySpellChecker, iface=ISpellChecker)
示例#45
0
    def test_kaltura_info(self):
        context = testing.DummyModel()
        request = testing.DummyRequest()
        from pyramid.interfaces import ISettings
        # kaltura_client_session missing
        settings = dict(
            kaltura_enabled='true',
            kaltura_partner_id='123456',
            kaltura_sub_partner_id='12345600',
            kaltura_admin_secret='123456789abcdef123456789abcdef12',
            kaltura_user_secret='0123456789abcdef123456789abcdef1',
            kaltura_kcw_uiconf_id='9999999',
            kaltura_player_uiconf_id='8888888',
            kaltura_player_cache_st='77777777',
        )
        karltesting.registerUtility(settings, ISettings)
        api = self._makeOne(context, request)
        self.assertEqual(
            api.kaltura_info,
            dict(
                enabled=True,
                partner_id='123456',
                sub_partner_id='12345600',
                session_url='http://example.com/kaltura_create_session.json',
                admin_secret='123456789abcdef123456789abcdef12',
                user_secret='0123456789abcdef123456789abcdef1',
                kcw_uiconf_id='9999999',
                player_uiconf_id='8888888',
                player_cache_st='77777777',
                local_user=None,
            ))
        # secrets are not sent to client
        self.assertEqual(
            api.render_karl_client_data(),
            '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456", "session_url": "http://example.com/kaltura_create_session.json"}};\n</script>'
        )

        settings['kaltura_client_session'] = 'false'
        api = self._makeOne(context, request)
        self.assertEqual(
            api.kaltura_info,
            dict(
                enabled=True,
                partner_id='123456',
                sub_partner_id='12345600',
                session_url='http://example.com/kaltura_create_session.json',
                admin_secret='123456789abcdef123456789abcdef12',
                user_secret='0123456789abcdef123456789abcdef1',
                kcw_uiconf_id='9999999',
                player_uiconf_id='8888888',
                player_cache_st='77777777',
                local_user=None,
            ))
        # secrets are not sent to client
        self.assertEqual(
            api.render_karl_client_data(),
            '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456", "session_url": "http://example.com/kaltura_create_session.json"}};\n</script>'
        )

        settings['kaltura_client_session'] = 'true'
        api = self._makeOne(context, request)
        self.assertEqual(
            api.kaltura_info,
            dict(
                enabled=True,
                partner_id='123456',
                sub_partner_id='12345600',
                admin_secret='123456789abcdef123456789abcdef12',
                user_secret='0123456789abcdef123456789abcdef1',
                kcw_uiconf_id='9999999',
                player_uiconf_id='8888888',
                player_cache_st='77777777',
                local_user=None,
                # no session_url means client side session management
            ))
        # secrets are sent to client
        self.assertEqual(
            api.render_karl_client_data(),
            '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"admin_secret": "123456789abcdef123456789abcdef12", "user_secret": "0123456789abcdef123456789abcdef1", "sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456"}};\n</script>'
        )
示例#46
0
 def _registerAlerts(self):
     from karl.utilities.interfaces import IAlerts
     from karl.testing import registerUtility
     alerts = DummyAlerts()
     registerUtility(alerts, IAlerts)
     return alerts
示例#47
0
文件: test_api.py 项目: araymund/karl
    def test_kaltura_info(self):
        context = testing.DummyModel()
        request = testing.DummyRequest()
        from pyramid.interfaces import ISettings
        # kaltura_client_session missing
        settings = dict(
            kaltura_enabled = 'true',
            kaltura_partner_id = '123456',
            kaltura_sub_partner_id = '12345600',
            kaltura_admin_secret = '123456789abcdef123456789abcdef12',
            kaltura_user_secret = '0123456789abcdef123456789abcdef1',
            kaltura_kcw_uiconf_id = '9999999',
            kaltura_player_uiconf_id = '8888888',
            kaltura_player_cache_st = '77777777',
            )
        karltesting.registerUtility(settings, ISettings)
        api = self._makeOne(context, request)
        self.assertEqual(api.kaltura_info, dict(
            enabled = True,
            partner_id = '123456',
            sub_partner_id = '12345600',
            session_url = 'http://example.com/kaltura_create_session.json',
            admin_secret = '123456789abcdef123456789abcdef12',
            user_secret = '0123456789abcdef123456789abcdef1',
            kcw_uiconf_id = '9999999',
            player_uiconf_id = '8888888',
            player_cache_st = '77777777',
            local_user = None,
            ))
        # secrets are not sent to client
        self.assertEqual(api.render_karl_client_data(), '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456", "session_url": "http://example.com/kaltura_create_session.json"}};\n</script>')

        settings['kaltura_client_session'] = 'false'
        api = self._makeOne(context, request)
        self.assertEqual(api.kaltura_info, dict(
            enabled = True,
            partner_id = '123456',
            sub_partner_id = '12345600',
            session_url = 'http://example.com/kaltura_create_session.json',
            admin_secret = '123456789abcdef123456789abcdef12',
            user_secret = '0123456789abcdef123456789abcdef1',
            kcw_uiconf_id = '9999999',
            player_uiconf_id = '8888888',
            player_cache_st = '77777777',
            local_user = None,
            ))
        # secrets are not sent to client
        self.assertEqual(api.render_karl_client_data(), '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456", "session_url": "http://example.com/kaltura_create_session.json"}};\n</script>')

        settings['kaltura_client_session'] = 'true'
        api = self._makeOne(context, request)
        self.assertEqual(api.kaltura_info, dict(
            enabled = True,
            partner_id = '123456',
            sub_partner_id = '12345600',
            admin_secret = '123456789abcdef123456789abcdef12',
            user_secret = '0123456789abcdef123456789abcdef1',
            kcw_uiconf_id = '9999999',
            player_uiconf_id = '8888888',
            player_cache_st = '77777777',
            local_user = None,
            # no session_url means client side session management
            ))
        # secrets are sent to client
        self.assertEqual(api.render_karl_client_data(), '<script type="text/javascript">\nwindow.karl_client_data = {"date_format": "en-US", "kaltura": {"admin_secret": "123456789abcdef123456789abcdef12", "user_secret": "0123456789abcdef123456789abcdef1", "sub_partner_id": "12345600", "player_uiconf_id": "8888888", "enabled": true, "local_user": null, "player_cache_st": "77777777", "kcw_uiconf_id": "9999999", "partner_id": "123456"}};\n</script>')
示例#48
0
 def _registerMailer(self):
     from repoze.sendmail.interfaces import IMailDelivery
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     return mailer
 def _registerMailer(self):
     from repoze.sendmail.interfaces import IMailDelivery
     mailer = karltesting.DummyMailer()
     karltesting.registerUtility(mailer, IMailDelivery)
     return mailer
示例#50
0
    def test_handle_submit_success(self):
        from karl.models.interfaces import IProfile
        from repoze.lemonade.testing import registerContentFactory
        from repoze.sendmail.interfaces import IMailDelivery
        from repoze.workflow.testing import registerDummyWorkflow
        from karl.models.interfaces import ICommunity
        from zope.interface import directlyProvides
        workflow = registerDummyWorkflow('security')
        mailer = karltesting.DummyMailer()
        karltesting.registerUtility(mailer, IMailDelivery)
        registerContentFactory(DummyContent, IProfile)

        class DummyWhoPlugin(object):
            def remember(self, environ, identity):
                self.identity = identity
                return []

        request = self._makeRequest()
        community = testing.DummyModel()
        profiles = testing.DummyModel()
        community['profiles'] = profiles
        community.users = karltesting.DummyUsers()
        community.members_group_name = 'community:members'
        directlyProvides(community, ICommunity)
        context = self._makeContext()
        community['invite'] = context
        community.title = 'Community'
        community.description = 'Community'
        community.sessions = DummySessions()
        context.email = '*****@*****.**'
        controller = self._makeOne(context, request)
        converted = {
            'password': '******',
            'password_confirm': '1',
            'username': '******',
            'firstname': 'firstname',
            'lastname': 'lastname',
            'phone': 'phone',
            'extension': 'extension',
            'department': 'department',
            'position': 'position',
            'organization': 'organization',
            'location': 'location',
            'country': 'country',
            'websites': ['website'],
            'languages': 'languages',
            'date_format': 'en-US',
            'biography': 'bio',
        }
        karltesting.registerDummyRenderer(
            'karl.views:templates/email_accept_invitation.pt')
        response = controller.handle_submit(converted)
        self.assertEqual(response.location,
                         'http://example.com/?status_message=Welcome%21')
        self.assertEqual(community.users.added,
                         ('username', 'username', '1', ['community:members']))
        profiles = community['profiles']
        self.failUnless('username' in profiles)
        self.assertEqual(workflow.initialized, [profiles['username']])
        profile = profiles['username']
        self.assertEqual('phone', profile.phone)
        self.assertEqual('firstname', profile.firstname)
        self.assertEqual('lastname', profile.lastname)
        self.assertEqual('bio', profile.biography)
        self.failIf('invite' in community)
        self.assertEqual(len(mailer), 1)