Beispiel #1
0
 def _create_random_entity_class(self, pk=None, rk=None):
     '''
     Creates a class-based entity with fixed values, using all
     of the supported data types.
     '''
     partition = pk if pk is not None else self.get_resource_name('pk')
     row = rk if rk is not None else self.get_resource_name('rk')
     entity = Entity()
     entity.PartitionKey = partition
     entity.RowKey = row
     entity.age = 39
     entity.sex = 'male'
     entity.name = 'John Doe'
     entity.married = True
     entity.deceased = False
     entity.optional = None
     entity.evenratio = 3.0
     entity.ratio = 3.1
     entity.large = 933311100
     entity.Birthday = datetime(1973, 10, 4)
     entity.birthday = datetime(1970, 10, 4)
     entity.binary = EntityProperty(EdmType.BINARY, b'binary')
     entity.other = EntityProperty(EdmType.INT32, 20)
     entity.clsid = EntityProperty(
         EdmType.GUID, 'c9da6455-213d-42c9-9a79-3e9149a57833')
     return entity
Beispiel #2
0
    def create_entity_class(self):
        '''
        Creates a class-based entity with fixed values, using all of the supported data types.
        '''
        entity = Entity()

        # Partition key and row key must be strings and are required
        entity.PartitionKey = 'pk{}'.format(str(uuid.uuid4()).replace('-', ''))
        entity.RowKey = 'rk{}'.format(str(uuid.uuid4()).replace('-', ''))

        # Some basic types are inferred
        entity.age = 39  # EdmType.INT64
        entity.large = 933311100  # EdmType.INT64
        entity.sex = 'male'  # EdmType.STRING
        entity.married = True  # EdmType.BOOLEAN
        entity.ratio = 3.1  # EdmType.DOUBLE
        entity.birthday = datetime(1970, 10, 4)  # EdmType.DATETIME

        # Binary, Int32 and GUID must be explicitly typed
        entity.binary = EntityProperty(EdmType.BINARY, b'xyz')
        entity.other = EntityProperty(EdmType.INT32, 20)
        entity.clsid = EntityProperty(EdmType.GUID, 'c9da6455-213d-42c9-9a79-3e9149a57833')
        return entity