예제 #1
0
    def setUp(self):
        super(TestUsersContactsInboxesSource, self).setUp()

        self.org_unit, self.admin_unit = create(
            Builder('fixture').with_admin_unit().with_org_unit())

        org_unit_2 = create(
            Builder('org_unit').id('client2').with_default_groups().having(
                title='Client2', admin_unit=self.admin_unit))

        create(
            Builder('ogds_user').having(firstname=u'Test',
                                        lastname=u'User').assign_to_org_units(
                                            [self.org_unit]))
        create(
            Builder('ogds_user').id('hugo.boss').having(
                firstname=u'Hugo',
                lastname=u'Boss').assign_to_org_units([self.org_unit]))
        create(
            Builder('ogds_user').id('robin.hood').having(
                firstname=u'Robin',
                lastname=u'Hood').assign_to_org_units([org_unit_2]))

        create(
            Builder('contact').having(firstname=u'Lara',
                                      lastname=u'Croft',
                                      email=u'*****@*****.**'))
        create(
            Builder('contact').having(firstname=u'Super',
                                      lastname=u'M\xe4n',
                                      email='*****@*****.**'))

        self.source = UsersContactsInboxesSource(self.portal)
예제 #2
0
class TestUsersContactsInboxesSourceInt(SolrMockupTestCase):

    schema = resource_string(
        'opengever.ogds.base.tests',
        os.path.join(
            'data',
            'solr_user_contacts_inboxes_source_schema.json'),
    )
    search = resource_string(
        'opengever.ogds.base.tests',
        os.path.join(
            'data',
            'solr_user_contacts_inboxes_source_search.json'),
    )

    def setUp(self):
        super(TestUsersContactsInboxesSourceInt, self).setUp()
        self.source = UsersContactsInboxesSource(self.portal)

    def test_contacts_appear_in_solr_result(self):
        query_string = u'B\xc3\xbcu'
        terms = self.source.search(query_string)
        self.assertEquals([u'Lehner-Baum\xe4nn Maria'],
                          [term.title for term in terms])
        self.assertEquals([u'contact:lehner-baumann-maria'],
                          [term.value for term in terms])
예제 #3
0
    def setUp(self):
        super(SolrMockupTestCase, self).setUp()
        assert self.schema is not None, 'A path for Solr schema is needed'
        conn = MagicMock(name='SolrConnection')
        conn.get = MagicMock(name='get',
                             return_value=SolrResponse(
                                 body=self.schema,
                                 status=200,
                             ))

        manager = MagicMock(name='SolrConnectionManager')
        manager.connection = conn
        manager.schema = SolrSchema(manager)

        solr = getUtility(ISolrSearch)
        solr._manager = manager

        assert self.search is not None, 'A path for Solr search is needed'
        solr.search = MagicMock(name='search',
                                return_value=SolrResponse(
                                    body=self.search,
                                    status=200,
                                ))
        self.solr = solr
        self.source = UsersContactsInboxesSource(self.portal)
예제 #4
0
    def setUp(self):
        super(TestUsersContactsInboxesSource, self).setUp()

        self.org_unit, self.admin_unit = create(
            Builder('fixture').with_admin_unit().with_org_unit())

        org_unit_2 = create(
            Builder('org_unit').id('org-unit-2').with_default_groups().having(
                title='Org Unit 2', admin_unit=self.admin_unit))

        disabled_unit = create(
            Builder('org_unit').id('org-unit-3').having(
                title=u'Steueramt', enabled=False,
                admin_unit=self.admin_unit).with_default_groups())

        create(
            Builder('ogds_user').having(firstname=u'Test',
                                        lastname=u'User').assign_to_org_units(
                                            [self.org_unit]))
        create(
            Builder('ogds_user').id('hugo.boss').having(
                firstname=u'Hugo',
                lastname=u'Boss').assign_to_org_units([self.org_unit]))
        create(
            Builder('ogds_user').id('robin.hood').having(
                firstname=u'Robin',
                lastname=u'Hood').assign_to_org_units([org_unit_2]))

        create(
            Builder('ogds_user').id('simon.says').having(
                firstname='Simon',
                lastname='Says').assign_to_org_units([disabled_unit]))

        create(
            Builder('contact').having(firstname=u'Lara',
                                      lastname=u'Croft',
                                      email=u'*****@*****.**'))
        create(
            Builder('contact').having(firstname=u'Super',
                                      lastname=u'M\xe4n',
                                      email='*****@*****.**'))

        self.source = UsersContactsInboxesSource(self.portal)
예제 #5
0
    def setUp(self):
        super(TestUsersContactsInboxesSource, self).setUp()

        self.org_unit, self.admin_unit = create(
            Builder('fixture').with_admin_unit().with_org_unit())

        org_unit_2 = create(Builder('org_unit')
                            .id('client2')
                            .with_default_groups()
                            .having(title='Client2',
                                    admin_unit=self.admin_unit))

        disabled_unit = create(Builder('org_unit')
                               .id('client3')
                               .having(title=u'Steueramt',
                                       enabled=False,
                                       admin_unit=self.admin_unit)
                               .with_default_groups())

        create(Builder('ogds_user')
               .having(firstname=u'Test', lastname=u'User')
               .assign_to_org_units([self.org_unit]))
        create(Builder('ogds_user')
               .id('hugo.boss')
               .having(firstname=u'Hugo', lastname=u'Boss')
               .assign_to_org_units([self.org_unit]))
        create(Builder('ogds_user').id('robin.hood')
               .having(firstname=u'Robin', lastname=u'Hood')
               .assign_to_org_units([org_unit_2]))

        create(Builder('ogds_user').id('simon.says')
               .having(firstname='Simon', lastname='Says')
               .assign_to_org_units([disabled_unit]))

        create(Builder('contact')
               .having(firstname=u'Lara', lastname=u'Croft',
                       email=u'*****@*****.**'))
        create(Builder('contact')
               .having(firstname=u'Super', lastname=u'M\xe4n',
                       email='*****@*****.**'))

        self.source = UsersContactsInboxesSource(self.portal)
예제 #6
0
class TestUsersContactsInboxesSourceInt(SolrMockupTestCase):

    schema = resource_string(
        'opengever.ogds.base.tests',
        os.path.join('data', 'solr_user_contacts_inboxes_source_schema.json'),
    )
    search = resource_string(
        'opengever.ogds.base.tests',
        os.path.join('data', 'solr_user_contacts_inboxes_source_search.json'),
    )

    def setUp(self):
        super(TestUsersContactsInboxesSourceInt, self).setUp()
        self.source = UsersContactsInboxesSource(self.portal)

    def test_contacts_appear_in_solr_result(self):
        query_string = u'B\xc3\xbcu'
        terms = self.source.search(query_string)
        self.assertEquals([u'Lehner-Baum\xe4nn Maria'],
                          [term.title for term in terms])
        self.assertEquals([u'contact:lehner-baumann-maria'],
                          [term.value for term in terms])
예제 #7
0
 def setUp(self):
     super(TestUsersContactsInboxesSourceInt, self).setUp()
     self.source = UsersContactsInboxesSource(self.portal)
예제 #8
0
class TestUsersContactsInboxesSource(FunctionalTestCase):

    use_default_fixture = False

    def setUp(self):
        super(TestUsersContactsInboxesSource, self).setUp()

        self.org_unit, self.admin_unit = create(
            Builder('fixture').with_admin_unit().with_org_unit())

        org_unit_2 = create(Builder('org_unit')
                            .id('client2')
                            .with_default_groups()
                            .having(title='Client2',
                                    admin_unit=self.admin_unit))

        disabled_unit = create(Builder('org_unit')
                               .id('client3')
                               .having(title=u'Steueramt',
                                       enabled=False,
                                       admin_unit=self.admin_unit)
                               .with_default_groups())

        create(Builder('ogds_user')
               .having(firstname=u'Test', lastname=u'User')
               .assign_to_org_units([self.org_unit]))
        create(Builder('ogds_user')
               .id('hugo.boss')
               .having(firstname=u'Hugo', lastname=u'Boss')
               .assign_to_org_units([self.org_unit]))
        create(Builder('ogds_user').id('robin.hood')
               .having(firstname=u'Robin', lastname=u'Hood')
               .assign_to_org_units([org_unit_2]))

        create(Builder('ogds_user').id('simon.says')
               .having(firstname='Simon', lastname='Says')
               .assign_to_org_units([disabled_unit]))

        create(Builder('contact')
               .having(firstname=u'Lara', lastname=u'Croft',
                       email=u'*****@*****.**'))
        create(Builder('contact')
               .having(firstname=u'Super', lastname=u'M\xe4n',
                       email='*****@*****.**'))

        self.source = UsersContactsInboxesSource(self.portal)

    def test_all_ogds_users_are_valid(self):
        self.assertIn('test_user_1_', self.source)
        self.assertIn('hugo.boss', self.source)
        self.assertIn('robin.hood', self.source)

    def test_users_from_inactive_orgunits_are_valid_but_not_found_by_search(self):
        self.assertIn('simon.says', self.source)
        self.assertEquals([], self.source.search('simon'))

    def test_return_no_search_result_for_inactive_orgunits(self):
        result = self.source.search('Steueramt')

        self.assertFalse(result,
                         'Expect no result, since the Steueramt is disabled')

    def test_not_existing_users(self):
        self.assertNotIn('dummy.user', self.source)

    def test_get_term_by_token(self):
        term = self.source.getTermByToken('hugo.boss')
        self.assertEquals('hugo.boss', term.token)
        self.assertEquals('hugo.boss', term.value)
        self.assertEquals('Boss Hugo (hugo.boss)', term.title)

    def test_inboxes_are_valid(self):
        self.assertIn('inbox:client1', self.source)
        self.assertIn('inbox:client2', self.source)

    def test_contacts_are_valid(self):
        self.assertIn('contact:croft-lara', self.source)
        self.assertIn('contact:man-super', self.source)

    def test_search_contacts(self):
        result = self.source.search('Lara')

        self.assertEquals(1, len(result), 'Expect 1 contact in result')
        self.assertEquals('contact:croft-lara', result[0].token)
        self.assertEquals('contact:croft-lara', result[0].value)
        self.assertEquals('Croft Lara ([email protected])', result[0].title)

    def test_search_ogds_users(self):
        self.assertEquals('hugo.boss', self.source.search('Hugo')[0].token)
        self.assertEquals('robin.hood', self.source.search('Rob')[0].token)
예제 #9
0
class TestUsersContactsInboxesSource(FunctionalTestCase):

    use_default_fixture = False

    def setUp(self):
        super(TestUsersContactsInboxesSource, self).setUp()

        self.org_unit, self.admin_unit = create(
            Builder('fixture').with_admin_unit().with_org_unit())

        org_unit_2 = create(
            Builder('org_unit').id('client2').with_default_groups().having(
                title='Client2', admin_unit=self.admin_unit))

        disabled_unit = create(
            Builder('org_unit').id('client3').having(
                title=u'Steueramt', enabled=False,
                admin_unit=self.admin_unit).with_default_groups())

        create(
            Builder('ogds_user').having(firstname=u'Test',
                                        lastname=u'User').assign_to_org_units(
                                            [self.org_unit]))
        create(
            Builder('ogds_user').id('hugo.boss').having(
                firstname=u'Hugo',
                lastname=u'Boss').assign_to_org_units([self.org_unit]))
        create(
            Builder('ogds_user').id('robin.hood').having(
                firstname=u'Robin',
                lastname=u'Hood').assign_to_org_units([org_unit_2]))

        create(
            Builder('ogds_user').id('simon.says').having(
                firstname='Simon',
                lastname='Says').assign_to_org_units([disabled_unit]))

        create(
            Builder('contact').having(firstname=u'Lara',
                                      lastname=u'Croft',
                                      email=u'*****@*****.**'))
        create(
            Builder('contact').having(firstname=u'Super',
                                      lastname=u'M\xe4n',
                                      email='*****@*****.**'))

        self.source = UsersContactsInboxesSource(self.portal)

    def test_all_ogds_users_are_valid(self):
        self.assertIn('test_user_1_', self.source)
        self.assertIn('hugo.boss', self.source)
        self.assertIn('robin.hood', self.source)

    def test_users_from_inactive_orgunits_are_valid_but_not_found_by_search(
            self):
        self.assertIn('simon.says', self.source)
        self.assertEquals([], self.source.search('simon'))

    def test_return_no_search_result_for_inactive_orgunits(self):
        result = self.source.search('Steueramt')

        self.assertFalse(result,
                         'Expect no result, since the Steueramt is disabled')

    def test_not_existing_users(self):
        self.assertNotIn('dummy.user', self.source)

    def test_get_term_by_token(self):
        term = self.source.getTermByToken('hugo.boss')
        self.assertEquals('hugo.boss', term.token)
        self.assertEquals('hugo.boss', term.value)
        self.assertEquals('Boss Hugo (hugo.boss)', term.title)

    def test_inboxes_are_valid(self):
        self.assertIn('inbox:client1', self.source)
        self.assertIn('inbox:client2', self.source)

    def test_contacts_are_valid(self):
        self.assertIn('contact:croft-lara', self.source)
        self.assertIn('contact:man-super', self.source)

    def test_search_contacts(self):
        result = self.source.search('Lara')

        self.assertEquals(1, len(result), 'Expect 1 contact in result')
        self.assertEquals('contact:croft-lara', result[0].token)
        self.assertEquals('contact:croft-lara', result[0].value)
        self.assertEquals('Croft Lara ([email protected])', result[0].title)

    def test_search_ogds_users(self):
        self.assertEquals('hugo.boss', self.source.search('Hugo')[0].token)
        self.assertEquals('robin.hood', self.source.search('Rob')[0].token)
예제 #10
0
 def setUp(self):
     super(TestUsersContactsInboxesSourceInt, self).setUp()
     self.source = UsersContactsInboxesSource(self.portal)