def test_009a_converter(self): rules = [ Lookup('normal', table={'message': 'lookup'}), Lookup('to_upper', table={'uppercase': 'lookup'}), Upper('normal'), Upper('to_upper'), ] converter = Converter(rules) self.assertEqual(len(converter.rules), 4) converter.apply(self.data) self.assertEqual(self.data['normal'], 'LOOKUP') self.assertEqual(self.data['to_upper'], 'LOOKUP')
def test_005b_loopkup_icase(self): table = {'mEsSaGe': 'lookup'} rule = Lookup('normal', table=table) rule.apply(self.data) self.assertEqual(self.data['normal'], 'message') rule = Lookup('normal', table=table, icase=True) rule.apply(self.data) self.assertEqual(self.data['normal'], 'lookup')
def test_005a_lookup(self): table = {'message': 'lookup'} rule = Lookup('normal', table=table) rule.apply(self.data) self.assertEqual(self.data['normal'], 'lookup') Lookup('missing', table=table).apply(self.data) self.assertTrue('missing' not in self.data) Lookup('none').apply(self.data) self.assertIsNone(self.data['none'])
def test_005a_lookup(self): table = {'message': 'lookup'} rule = Lookup('normal', table=table) rule.apply(self.data) self.assertEqual(self.data['normal'], 'lookup')