def test_renames_single_key(self): test_data = [ {'old_key': 'a_value'}, {'old_key': 'a_value'} ] key_map = { 'old_key': 'new_key' } p = Rename(key_map) p.bind(test_data) for i in p: self.assertIn('new_key', i) self.assertEquals(i['new_key'], 'a_value') self.assertNotIn('old_key', i)
def test_renames_multiple_keys(self): test_data = [ { 'old_key1': 'a_value1', 'old_key2': 'a_value2' }, { 'old_key1': 'a_value1', 'old_key2': 'a_value2' }, ] key_map = { 'old_key1': 'new_key1', 'old_key2': 'new_key2' } p = Rename(key_map) p.bind(test_data) for i in p: self.assertIn('new_key1', i) self.assertEquals(i['new_key1'], 'a_value1') self.assertNotIn('old_key1', i) self.assertIn('new_key2', i) self.assertEquals(i['new_key2'], 'a_value2') self.assertNotIn('old_key2', i)