def test_009b_converter_from_dict(self): rulers = { 'rulers': [ { 'type': 'lookup', 'rules': [ { 'fieldname': 'normal', 'table': {'message': 'lookup'} }, { 'fieldname': 'to_upper', 'table': {'uppercase': 'lookup'} }, ] }, { 'type': 'upper', 'rules': [ {'fieldname': 'normal'}, {'fieldname': 'to_upper'}, ] } ] } converter = Converter.from_dict(rulers) self.assertEqual(len(converter.rulers), 2) converter.apply(self.data) self.assertEqual(self.data['normal'], 'LOOKUP') self.assertEqual(self.data['to_upper'], 'LOOKUP')
def test_009a_converter(self): lookups = [ Lookup('normal', table={'message': 'lookup'}), Lookup('to_upper', table={'uppercase': 'lookup'}), ] lookupruler = Ruler(Lookup, lookups) uppers = [ Upper('normal'), Upper('to_upper'), ] upperruler = Ruler(Upper, uppers) converter = Converter([lookupruler, upperruler]) self.assertEqual(len(converter.rulers), 2) converter.apply(self.data) self.assertEqual(self.data['normal'], 'LOOKUP') self.assertEqual(self.data['to_upper'], 'LOOKUP')