Ejemplo n.º 1
0
 def test_is_not_document_type_if_missing_document_trait(self):
     self.shapes['NonDocStructure'] = {
         'type': 'structure',
         'members': {},
     }
     self.assertFalse(
         is_document_type(self.get_shape_model('NonDocStructure')))
Ejemplo n.º 2
0
 def _raise_if_document_type_found(self, value, member_shape):
     # Shorthand syntax does not have support for explicit typing and
     # instead relies on the model to do type coercion. However, document
     # types are unmodeled. So using short hand syntax on a document type
     # would result in all values being typed as strings (e.g. 1 -> "1",
     # null -> "null") which is probably not desired. So blocking the use
     # of document types allows us to add proper support for them in the
     # future in a backwards compatible way.
     if value is not None and is_document_type(member_shape):
         raise DocumentTypesNotSupportedError()
Ejemplo n.º 3
0
 def _get_argument_type_name(self, shape, default):
     if is_json_value_header(shape):
         return 'JSON'
     if is_document_type(shape):
         return 'document'
     if is_streaming_blob_type(shape):
         return 'streaming blob'
     if is_tagged_union_type(shape):
         return 'tagged union structure'
     return default
 def _get_argument_type_name(self, shape, default):
     if is_json_value_header(shape):
         return 'JSON'
     if is_document_type(shape):
         return 'document'
     return default
Ejemplo n.º 5
0
 def test_is_not_document_type_if_not_structure(self):
     self.shapes['String'] = {'type': 'string'}
     self.assertFalse(is_document_type(self.get_shape_model('String')))
Ejemplo n.º 6
0
 def test_is_document_type(self):
     self.shapes['DocStructure'] = self.get_doc_type_shape_definition()
     self.assertTrue(is_document_type(self.get_shape_model('DocStructure')))