def METHOD_NAME(self, key, valid_value, required=False):
    def _validate(metadata):
        getattr(metadata, 'validate_' + key)()
    metadata = OpenIDProviderMetadata()
    if required:
        with self.assertRaises(ValueError) as cm:
            _validate(metadata)
        self.assertEqual(f'"{key}" is required', str(cm.exception))
    else:
        _validate(metadata)
    # not array
    metadata = OpenIDProviderMetadata({key: 'foo'})
    with self.assertRaises(ValueError) as cm:
        _validate(metadata)
    self.assertIn('JSON array', str(cm.exception))
    # valid
    metadata = OpenIDProviderMetadata({key: valid_value})
    _validate(metadata)