def test_create_get_fn(self, value_type, values, number, expected): info = variants_pb2.Variant().info set_fn = vcf_constants.SET_FN_LOOKUP[value_type] set_fn(info, 'field', values) get_fn = vcf_constants.create_get_fn(value_type, number) actual = get_fn(info, 'field') self.assertEqual(actual, expected)
def _create_get_fn_cache(fields): """Returns a dictionary from field to a callable that extracts its value.""" return { field.id: vcf_constants.create_get_fn(field.type, field.number) for field in fields }