@@ -1318,6 +1318,33 @@ def test__set_pb_meaning_w_value_unset(orig_meaning):
13181318 assert value_pb .meaning == orig_meaning
13191319
13201320
1321+ def test__set_pb_meaning_w_list_and_single_value ():
1322+ """
1323+ v2.20.2 uses a tuple to represent list meanings (https://github.com/googleapis/python-datastore/pull/575)
1324+
1325+ This check ensures _set_pb_meaning_from_entity is backwards
1326+ compatible with the old meaning style, still used by python-ndb
1327+ """
1328+ from google .cloud .datastore_v1 .types import entity as entity_pb2
1329+ from google .cloud .datastore .helpers import _set_pb_meaning_from_entity
1330+ from google .cloud .datastore .entity import Entity
1331+
1332+ orig_root_meaning = 1
1333+ updated_meaning = 22
1334+ orig_pb = entity_pb2 .Entity ()
1335+ value_pb = orig_pb ._pb .properties .get_or_create ("value" )
1336+ value_pb .meaning = orig_root_meaning
1337+ sub_value_pb1 = value_pb .array_value .values .add ()
1338+ sub_value_pb2 = value_pb .array_value .values .add ()
1339+
1340+ entity = Entity (key = "key" )
1341+ entity ._meanings = {"value" : (updated_meaning , None )}
1342+ _set_pb_meaning_from_entity (entity , "value" , None , value_pb , is_list = True )
1343+ assert value_pb .meaning == orig_root_meaning
1344+ assert sub_value_pb1 .meaning == updated_meaning
1345+ assert sub_value_pb2 .meaning == updated_meaning
1346+
1347+
13211348def test__array_w_meaning_end_to_end ():
13221349 """
13231350 Test proto->entity->proto with an array with a meaning field
0 commit comments