Python google.appengine.ext.ndb.PickleProperty() Examples

The following are 5 code examples of google.appengine.ext.ndb.PickleProperty(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module google.appengine.ext.ndb , or try the search function .
Example #1
Source File: serializable_test.py    From luci-py with Apache License 2.0 4 votes vote down vote up
def test_simple_properties(self):
    """Simple properties are unmodified in to_serializable_dict()."""
    class Entity(ndb.Model, serializable.SerializableModelMixin):
      blob_prop = ndb.BlobProperty()
      bool_prop = ndb.BooleanProperty()
      float_prop = ndb.FloatProperty()
      int_prop = ndb.IntegerProperty()
      json_prop = ndb.JsonProperty()
      pickle_prop = ndb.PickleProperty()
      str_prop = ndb.StringProperty()
      text_prop = ndb.TextProperty()

    # Test data in simple dict form.
    as_serializable_dict = {
      'blob_prop': 'blob',
      'bool_prop': True,
      'float_prop': 3.14,
      'int_prop': 42,
      'json_prop': ['a list', 'why', 'not?'],
      'pickle_prop': {'some': 'dict'},
      'str_prop': 'blah-blah',
      'text_prop': 'longer blah-blah',
    }

    # Same data but in entity form. Constructing entity directly from
    # |as_serializable_dict| works only if it contains only simple properties
    # (that look the same in serializable dict and entity form).
    as_entity = Entity(**as_serializable_dict)

    # Ensure all simple properties (from _SIMPLE_PROPERTIES) are covered.
    self.assertEqual(
        set(serializable._SIMPLE_PROPERTIES),
        set(prop.__class__ for prop in Entity._properties.values()))

    # Check entity -> serializable dict conversion.
    self.assertEqual(
        as_serializable_dict,
        as_entity.to_serializable_dict())

    # Check serializable dict -> Entity conversion.
    self.assertEqual(
        as_entity,
        Entity.from_serializable_dict(as_serializable_dict)) 
Example #2
Source File: serializable_test.py    From luci-py with Apache License 2.0 4 votes vote down vote up
def test_simple_properties(self):
    """Simple properties are unmodified in to_serializable_dict()."""
    class Entity(ndb.Model, serializable.SerializableModelMixin):
      blob_prop = ndb.BlobProperty()
      bool_prop = ndb.BooleanProperty()
      float_prop = ndb.FloatProperty()
      int_prop = ndb.IntegerProperty()
      json_prop = ndb.JsonProperty()
      pickle_prop = ndb.PickleProperty()
      str_prop = ndb.StringProperty()
      text_prop = ndb.TextProperty()

    # Test data in simple dict form.
    as_serializable_dict = {
      'blob_prop': 'blob',
      'bool_prop': True,
      'float_prop': 3.14,
      'int_prop': 42,
      'json_prop': ['a list', 'why', 'not?'],
      'pickle_prop': {'some': 'dict'},
      'str_prop': 'blah-blah',
      'text_prop': 'longer blah-blah',
    }

    # Same data but in entity form. Constructing entity directly from
    # |as_serializable_dict| works only if it contains only simple properties
    # (that look the same in serializable dict and entity form).
    as_entity = Entity(**as_serializable_dict)

    # Ensure all simple properties (from _SIMPLE_PROPERTIES) are covered.
    self.assertEqual(
        set(serializable._SIMPLE_PROPERTIES),
        set(prop.__class__ for prop in Entity._properties.values()))

    # Check entity -> serializable dict conversion.
    self.assertEqual(
        as_serializable_dict,
        as_entity.to_serializable_dict())

    # Check serializable dict -> Entity conversion.
    self.assertEqual(
        as_entity,
        Entity.from_serializable_dict(as_serializable_dict)) 
Example #3
Source File: serializable_test.py    From luci-py with Apache License 2.0 4 votes vote down vote up
def test_simple_properties(self):
    """Simple properties are unmodified in to_serializable_dict()."""
    class Entity(ndb.Model, serializable.SerializableModelMixin):
      blob_prop = ndb.BlobProperty()
      bool_prop = ndb.BooleanProperty()
      float_prop = ndb.FloatProperty()
      int_prop = ndb.IntegerProperty()
      json_prop = ndb.JsonProperty()
      pickle_prop = ndb.PickleProperty()
      str_prop = ndb.StringProperty()
      text_prop = ndb.TextProperty()

    # Test data in simple dict form.
    as_serializable_dict = {
      'blob_prop': 'blob',
      'bool_prop': True,
      'float_prop': 3.14,
      'int_prop': 42,
      'json_prop': ['a list', 'why', 'not?'],
      'pickle_prop': {'some': 'dict'},
      'str_prop': 'blah-blah',
      'text_prop': 'longer blah-blah',
    }

    # Same data but in entity form. Constructing entity directly from
    # |as_serializable_dict| works only if it contains only simple properties
    # (that look the same in serializable dict and entity form).
    as_entity = Entity(**as_serializable_dict)

    # Ensure all simple properties (from _SIMPLE_PROPERTIES) are covered.
    self.assertEqual(
        set(serializable._SIMPLE_PROPERTIES),
        set(prop.__class__ for prop in Entity._properties.values()))

    # Check entity -> serializable dict conversion.
    self.assertEqual(
        as_serializable_dict,
        as_entity.to_serializable_dict())

    # Check serializable dict -> Entity conversion.
    self.assertEqual(
        as_entity,
        Entity.from_serializable_dict(as_serializable_dict)) 
Example #4
Source File: serializable_test.py    From luci-py with Apache License 2.0 4 votes vote down vote up
def test_simple_properties(self):
    """Simple properties are unmodified in to_serializable_dict()."""
    class Entity(ndb.Model, serializable.SerializableModelMixin):
      blob_prop = ndb.BlobProperty()
      bool_prop = ndb.BooleanProperty()
      float_prop = ndb.FloatProperty()
      int_prop = ndb.IntegerProperty()
      json_prop = ndb.JsonProperty()
      pickle_prop = ndb.PickleProperty()
      str_prop = ndb.StringProperty()
      text_prop = ndb.TextProperty()

    # Test data in simple dict form.
    as_serializable_dict = {
      'blob_prop': 'blob',
      'bool_prop': True,
      'float_prop': 3.14,
      'int_prop': 42,
      'json_prop': ['a list', 'why', 'not?'],
      'pickle_prop': {'some': 'dict'},
      'str_prop': 'blah-blah',
      'text_prop': 'longer blah-blah',
    }

    # Same data but in entity form. Constructing entity directly from
    # |as_serializable_dict| works only if it contains only simple properties
    # (that look the same in serializable dict and entity form).
    as_entity = Entity(**as_serializable_dict)

    # Ensure all simple properties (from _SIMPLE_PROPERTIES) are covered.
    self.assertEqual(
        set(serializable._SIMPLE_PROPERTIES),
        set(prop.__class__ for prop in Entity._properties.values()))

    # Check entity -> serializable dict conversion.
    self.assertEqual(
        as_serializable_dict,
        as_entity.to_serializable_dict())

    # Check serializable dict -> Entity conversion.
    self.assertEqual(
        as_entity,
        Entity.from_serializable_dict(as_serializable_dict)) 
Example #5
Source File: serializable_test.py    From luci-py with Apache License 2.0 4 votes vote down vote up
def test_simple_properties(self):
    """Simple properties are unmodified in to_serializable_dict()."""
    class Entity(ndb.Model, serializable.SerializableModelMixin):
      blob_prop = ndb.BlobProperty()
      bool_prop = ndb.BooleanProperty()
      float_prop = ndb.FloatProperty()
      int_prop = ndb.IntegerProperty()
      json_prop = ndb.JsonProperty()
      pickle_prop = ndb.PickleProperty()
      str_prop = ndb.StringProperty()
      text_prop = ndb.TextProperty()

    # Test data in simple dict form.
    as_serializable_dict = {
      'blob_prop': 'blob',
      'bool_prop': True,
      'float_prop': 3.14,
      'int_prop': 42,
      'json_prop': ['a list', 'why', 'not?'],
      'pickle_prop': {'some': 'dict'},
      'str_prop': 'blah-blah',
      'text_prop': 'longer blah-blah',
    }

    # Same data but in entity form. Constructing entity directly from
    # |as_serializable_dict| works only if it contains only simple properties
    # (that look the same in serializable dict and entity form).
    as_entity = Entity(**as_serializable_dict)

    # Ensure all simple properties (from _SIMPLE_PROPERTIES) are covered.
    self.assertEqual(
        set(serializable._SIMPLE_PROPERTIES),
        set(prop.__class__ for prop in Entity._properties.values()))

    # Check entity -> serializable dict conversion.
    self.assertEqual(
        as_serializable_dict,
        as_entity.to_serializable_dict())

    # Check serializable dict -> Entity conversion.
    self.assertEqual(
        as_entity,
        Entity.from_serializable_dict(as_serializable_dict))