コード例 #1
0
class Person(BaseModel):
    Type = UnicodeAttribute(default='person')
    FirstName = UnicodeAttribute()
    LastName = UnicodeAttribute()
    Age = NumberAttribute(default=0)
    CreateDate = UTCDateTimeAttribute(attr_name='CreateDateTime')
    ValueList = ListAttribute()
    ValueMap = MapAttribute()
    DoesNotExist = DoesNotExist
コード例 #2
0
class TestModel(Model):
    '''Test model with meta'''
    class Meta(Model.Meta):
        table_name = 'falcano-map-attr-e2e'
        billing_mode = 'PAY_PER_REQUEST'

    PK = UnicodeAttribute(hash_key=True)
    SK = UnicodeAttribute(range_key=True)
    Data = MapAttribute()
    Type = UnicodeAttribute(default='test_map_attribute')
コード例 #3
0
ファイル: test_map_attribute.py プロジェクト: njsnx/falcano
def test_raw_map_json_serialize():
    raw = {"foo": "bar", "num": 3, "nested": {"nestedfoo": "nestedbar"}}

    serialized_raw = json.dumps(raw, sort_keys=True)
    serialized_attr_from_raw = json.dumps(
        TestModel(test_map=raw).test_map.as_dict(), sort_keys=True)
    serialized_attr_from_map = json.dumps(
        TestModel(test_map=MapAttribute(**raw)).test_map.as_dict(),
        sort_keys=True)

    assert serialized_attr_from_raw == serialized_raw
    assert serialized_attr_from_map == serialized_raw
コード例 #4
0
 class OuterMapAttribute(MapAttribute):
     mid_map = MapAttribute()
コード例 #5
0
ファイル: test_map_attribute.py プロジェクト: njsnx/falcano
class TestModel(Model):
    test_map = MapAttribute(attr_name="test_name", default={})
コード例 #6
0
ファイル: test_map_attribute.py プロジェクト: njsnx/falcano
 class InnerMapAttribute(MapAttribute):
     test_map = MapAttribute(attr_name='dyn_test_map')
コード例 #7
0
ファイル: test_map_attribute.py プロジェクト: njsnx/falcano
class TestDefaultsMap(MapAttribute):
    map_field = MapAttribute(default={})
    string_field = UnicodeAttribute(null=True)
コード例 #8
0
ファイル: test_map_attribute.py プロジェクト: njsnx/falcano
 class TypedMap(MapAttribute):
     test_map = MapAttribute()