Exemplo n.º 1
0
    def test_traits(self):
        """Basic traits test."""
        traitz = ['a', 'b']
        code = traits.create_code(traitz)

        self.assertEqual(_transform(code, ['a']), 'a')
        self.assertEqual(_transform(code, ['a', 'b']), 'a,b')
        self.assertEqual(_transform(code, ['b', 'a']), 'a,b')
        self.assertEqual(_transform(code, ['a', 'x', 'b']), 'a,b')
        self.assertEqual(_transform(code, ['a', 'x', 'b'], use_invalid=True),
                         'a,b,invalid')
        self.assertEqual(_transform(traits.create_code([]), ['a', 'x', 'b']),
                         '')
        self.assertEqual(
            _transform(traits.create_code([]), ['a', 'x', 'b'],
                       use_invalid=True), 'invalid')
Exemplo n.º 2
0
    def test_traits(self):
        """Basic traits test."""
        traitz = ['a', 'b']
        code = traits.create_code(traitz)

        self.assertEqual(_transform(code, ['a']), 'a')
        self.assertEqual(_transform(code, ['a', 'b']), 'a,b')
        self.assertEqual(_transform(code, ['b', 'a']), 'a,b')
        self.assertEqual(_transform(code, ['a', 'x', 'b']), 'a,b')
        self.assertEqual(_transform({}, ['a', 'x', 'b']), '')
Exemplo n.º 3
0
    def test_adding_traits(self):
        """Adding traits test."""
        code = traits.create_code([])

        self.assertEqual(
            _transform(code, ['a']),
            ''
        )

        self.assertEqual(
            _transform(code, ['a'], add_new=True),
            'a'
        )
Exemplo n.º 4
0
 def load_traits(self):
     """Load traits."""
     traitz = self.backend.get_default(z.path.traits(), default=[])
     _LOGGER.info('loading traits: %s', traitz)
     self.trait_codes = traits.create_code(traitz)