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')
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']), '')
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' )
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)