def test_dict_to_dynamic_metadata(self): with self.assertRaises(services.DynamicMetadataError): services._dict_to_dynamic_metadata([]) self.assertEqual( services._dict_to_dynamic_metadata({ 'version': '1.0', 'validation': { 'url': 'https://a.com/validate', 'patterns': [ { 'config_set': 'projects/foo', 'path': 'bar.cfg' }, { 'config_set': 'regex:services/.+', 'path': 'regex:.+' }, ] } }), service_config_pb2.ServiceDynamicMetadata( validation=service_config_pb2.Validator( url='https://a.com/validate', patterns=[ service_config_pb2.ConfigPattern( config_set='projects/foo', path='bar.cfg'), service_config_pb2.ConfigPattern( config_set='regex:services/.+', path='regex:.+'), ])))
def test_dict_to_dynamic_metadata(self): with self.assertRaises(services.DynamicMetadataError): services._dict_to_dynamic_metadata([]) self.assertEqual( services._dict_to_dynamic_metadata({ 'version': '1.0', 'validation': { 'url': 'https://a.com/validate', 'patterns': [ {'config_set': 'projects/foo', 'path': 'bar.cfg'}, {'config_set': 'regex:services/.+', 'path': 'regex:.+'}, ] } }), service_config_pb2.ServiceDynamicMetadata( validation=service_config_pb2.Validator( url='https://a.com/validate', patterns=[ service_config_pb2.ConfigPattern( config_set='projects/foo', path='bar.cfg'), service_config_pb2.ConfigPattern( config_set='regex:services/.+', path='regex:.+'), ] ) ) )
def mock_metadata_entity(self): dct = { 'version': '1.0', 'validation': { 'url': 'https://a.com/validate', 'patterns': [ {'config_set': 'projects/foo', 'path': 'bar.cfg'}, {'config_set': 'regex:services/.+', 'path': 'regex:.+'}, ] } } mck_meta = (services._dict_to_dynamic_metadata(dct).SerializeToString()) storage.ServiceDynamicMetadata( id='deadbeef', metadata=mck_meta, ).put()