@@ -3295,6 +3295,45 @@ class SomeKind(model.Model):
32953295 assert SomeKind .foo ._to_datastore (entity , data ) == {"foo.bar" }
32963296 assert data == {"foo.bar" : ["baz" , "boz" ]}
32973297
3298+ @staticmethod
3299+ def test__prepare_for_put ():
3300+ class SubKind (model .Model ):
3301+ bar = model .Property ()
3302+
3303+ class SomeKind (model .Model ):
3304+ foo = model .StructuredProperty (SubKind )
3305+
3306+ entity = SomeKind (foo = SubKind ())
3307+ entity .foo ._prepare_for_put = unittest .mock .Mock ()
3308+ SomeKind .foo ._prepare_for_put (entity )
3309+ entity .foo ._prepare_for_put .assert_called_once_with ()
3310+
3311+ @staticmethod
3312+ def test__prepare_for_put_repeated ():
3313+ class SubKind (model .Model ):
3314+ bar = model .Property ()
3315+
3316+ class SomeKind (model .Model ):
3317+ foo = model .StructuredProperty (SubKind , repeated = True )
3318+
3319+ entity = SomeKind (foo = [SubKind (), SubKind ()])
3320+ entity .foo [0 ]._prepare_for_put = unittest .mock .Mock ()
3321+ entity .foo [1 ]._prepare_for_put = unittest .mock .Mock ()
3322+ SomeKind .foo ._prepare_for_put (entity )
3323+ entity .foo [0 ]._prepare_for_put .assert_called_once_with ()
3324+ entity .foo [1 ]._prepare_for_put .assert_called_once_with ()
3325+
3326+ @staticmethod
3327+ def test__prepare_for_put_repeated_None ():
3328+ class SubKind (model .Model ):
3329+ bar = model .Property ()
3330+
3331+ class SomeKind (model .Model ):
3332+ foo = model .StructuredProperty (SubKind )
3333+
3334+ entity = SomeKind ()
3335+ SomeKind .foo ._prepare_for_put (entity ) # noop
3336+
32983337
32993338class TestLocalStructuredProperty :
33003339 @staticmethod
@@ -3397,6 +3436,45 @@ class Simple(model.Model):
33973436 expected = Simple ()
33983437 assert prop ._from_base_type (entity ) == expected
33993438
3439+ @staticmethod
3440+ def test__prepare_for_put ():
3441+ class SubKind (model .Model ):
3442+ bar = model .Property ()
3443+
3444+ class SomeKind (model .Model ):
3445+ foo = model .LocalStructuredProperty (SubKind )
3446+
3447+ entity = SomeKind (foo = SubKind ())
3448+ entity .foo ._prepare_for_put = unittest .mock .Mock ()
3449+ SomeKind .foo ._prepare_for_put (entity )
3450+ entity .foo ._prepare_for_put .assert_called_once_with ()
3451+
3452+ @staticmethod
3453+ def test__prepare_for_put_repeated ():
3454+ class SubKind (model .Model ):
3455+ bar = model .Property ()
3456+
3457+ class SomeKind (model .Model ):
3458+ foo = model .LocalStructuredProperty (SubKind , repeated = True )
3459+
3460+ entity = SomeKind (foo = [SubKind (), SubKind ()])
3461+ entity .foo [0 ]._prepare_for_put = unittest .mock .Mock ()
3462+ entity .foo [1 ]._prepare_for_put = unittest .mock .Mock ()
3463+ SomeKind .foo ._prepare_for_put (entity )
3464+ entity .foo [0 ]._prepare_for_put .assert_called_once_with ()
3465+ entity .foo [1 ]._prepare_for_put .assert_called_once_with ()
3466+
3467+ @staticmethod
3468+ def test__prepare_for_put_repeated_None ():
3469+ class SubKind (model .Model ):
3470+ bar = model .Property ()
3471+
3472+ class SomeKind (model .Model ):
3473+ foo = model .LocalStructuredProperty (SubKind )
3474+
3475+ entity = SomeKind ()
3476+ SomeKind .foo ._prepare_for_put (entity ) # noop
3477+
34003478
34013479class TestGenericProperty :
34023480 @staticmethod
0 commit comments