@@ -459,20 +459,24 @@ def test_query():
459459
460460@pytest .mark .usefixtures ("client_context" )
461461def test_legacy_local_structured_property_with_boolean (ds_entity ):
462- """Regression test for #623
462+ """Regression test for #623, #625
463463
464464 https://github.com/googleapis/python-ndb/issues/623
465+ https://github.com/googleapis/python-ndb/issues/625
465466 """
466467 children = [
467468 b"x\x9c \xab \xe2 \x96 bNJ,R`\xd0 b\x12 `\xac \x12 \xe1 \xe0 \x97 bN\xcb \xcf \x07 r9\xa5 "
468- b"\xd8 32\x15 r\xf3 s\x15 \x01 u_\x07 \n "
469+ b"\xd8 32\x15 r\xf3 s\x15 \x01 u_\x07 \n " ,
470+ b"x\x9c \xab \xe2 \x96 bNJ,R`\xd0 b\x12 `\xa8 \x12 \xe7 \xe0 \x97 bN\xcb \xcf \x07 ry\xa4 "
471+ b"\xb8 2Rsr\xf2 \x15 R\x12 S\x14 \x01 \x8e \xbf \x08 5" ,
469472 ]
473+
470474 entity_id = test_utils .system .unique_resource_id ()
471475 ds_entity (KIND , entity_id , children = children )
472476
473477 class OtherKind (ndb .Model ):
474478 foo = ndb .StringProperty ()
475- bar = ndb .BooleanProperty (default = True )
479+ bar = ndb .BooleanProperty (required = True , default = True )
476480
477481 class SomeKind (ndb .Model ):
478482 children = ndb .LocalStructuredProperty (
@@ -481,12 +485,19 @@ class SomeKind(ndb.Model):
481485
482486 entity = SomeKind .get_by_id (entity_id )
483487
484- assert len (entity .children ) == 1
488+ assert len (entity .children ) == 2
485489 assert entity .children [0 ].foo == "hi mom!"
486490 assert entity .children [0 ].bar is True
491+ assert entity .children [1 ].foo == "hello dad!"
492+ assert entity .children [1 ].bar is False
487493
488- entity .children [ 0 ]. foo = "hello dad!"
494+ entity .children . append ( OtherKind ( foo = "i'm in jail!" , bar = False ))
489495 entity .put ()
490496
491497 entity = SomeKind .get_by_id (entity_id )
492- assert entity .children [0 ].foo == "hello dad!"
498+ assert entity .children [0 ].foo == "hi mom!"
499+ assert entity .children [0 ].bar is True
500+ assert entity .children [1 ].foo == "hello dad!"
501+ assert entity .children [1 ].bar is False
502+ assert entity .children [2 ].foo == "i'm in jail!"
503+ assert entity .children [2 ].bar is False
0 commit comments