Beispiel #1
0
    def test_that_format_columns_transformation_are_applied(self):
        SourceResult = make_result_class(
            sentinel.backend,
            sentinel.name,
            format_columns={
                'fn': '{firstname}',
                'ln': '{lastname}',
                'name': '{firstname} {lastname}',
                'simple_error': '{missing}',
                'complex_error': '{missing[0][field]}',
                'super_complex_error': '{list[0][missing]}',
                'crazy_error': '{list[1][missing]}',
            },
        )

        r = SourceResult(self.fields)

        assert_that(
            r.fields,
            has_entries(
                fn='fn',
                ln='ln',
                name='fn ln',
                simple_error=None,
                complex_error=None,
                super_complex_error=None,
                crazy_error=None,
            ),
        )
Beispiel #2
0
    def test_source_name(self):
        SourceResult = make_result_class(sentinel.backend,
                                         sentinel.source_name)

        s = SourceResult({})

        assert_that(s.source, equal_to(sentinel.source_name))
Beispiel #3
0
    def test_deletable(self):
        SourceResult = make_result_class(
            sentinel.backend, sentinel.source_name, is_deletable=True
        )

        s = SourceResult({})

        assert_that(s.is_deletable, is_(True))
Beispiel #4
0
    def test_format_columns(self):
        SourceResult = make_result_class(
            sentinel.backend, sentinel.source_name, format_columns={'to': '{from}'}
        )

        s = SourceResult({})

        assert_that(s._format_columns, equal_to({'to': '{from}'}))
        assert_that(s._unique_column, none())
Beispiel #5
0
    def test_source_unique_column(self):
        SourceResult = make_result_class(
            sentinel.backend, sentinel.source_name, 'the-unique-column'
        )

        s = SourceResult({})

        assert_that(s._unique_column, equal_to('the-unique-column'))
        assert_that(s._format_columns, equal_to({}))
Beispiel #6
0
 def setUp(self):
     self.name = 'foo'
     self.unique_column = 'entryUUID'
     self.format_columns = {'firstname': '{givenName}'}
     self.ldap_config = Mock(_LDAPConfig)
     self.ldap_config.name.return_value = self.name
     self.ldap_config.unique_column.return_value = self.unique_column
     self.ldap_config.format_columns.return_value = self.format_columns
     self.SourceResult = make_result_class('ldap', self.name,
                                           self.unique_column,
                                           self.format_columns)
Beispiel #7
0
    def test_that_the_source_entry_id_is_added_to_relations(self):
        SourceResult = make_result_class('foo_backend',
                                         'foobar',
                                         unique_column='email')

        r = SourceResult({
            'fn': 'Foo',
            'ln': 'Bar',
            'email': '*****@*****.**'
        })

        assert_that(r.relations['source_entry_id'],
                    equal_to('*****@*****.**'))
 def load(self, config):
     self.SourceResult = make_result_class('chained-second-lookup-backend',
                                           'chained-second-lookup')
     return