[ https://issues.apache.org/jira/browse/BEAM-8405?focusedWorklogId=330686&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-330686 ]
ASF GitHub Bot logged work on BEAM-8405: ---------------------------------------- Author: ASF GitHub Bot Created on: 18/Oct/19 17:49 Start Date: 18/Oct/19 17:49 Worklog Time Spent: 10m Work Description: chamikaramj commented on pull request #9805: [BEAM-8405] Support embedded Datastore entities URL: https://github.com/apache/beam/pull/9805#discussion_r336605472 ########## File path: sdks/python/apache_beam/io/gcp/datastore/v1new/types_test.py ########## @@ -47,30 +49,52 @@ def setUp(self): # Don't do any network requests. _http=mock.MagicMock()) + def _assert_keys_equal(self, beam_type, client_type, expected_project): + self.assertEqual(beam_type.path_elements[0], client_type.kind) + self.assertEqual(beam_type.path_elements[1], client_type.id) + self.assertEqual(expected_project, client_type.project) + def testEntityToClientEntity(self): + # Test conversion from Beam type to client type. k = Key(['kind', 1234], project=self._PROJECT) kc = k.to_client_key() - exclude_from_indexes = ('efi1', 'efi2') + exclude_from_indexes = ('datetime', 'key') e = Entity(k, exclude_from_indexes=exclude_from_indexes) - ref = Key(['kind2', 1235]) - e.set_properties({'efi1': 'value', 'property': 'value', 'ref': ref}) + properties = { + 'datetime': datetime.datetime.utcnow(), + 'key_ref': Key(['kind2', 1235]), + 'bool': True, + 'float': 1.21, + 'int': 1337, + 'unicode': 'text', + 'bytes': b'bytes', + 'geopoint': GeoPoint(0.123, 0.456), + 'none': None, + 'list': [1, 2, 3], + 'entity': Entity(Key(['kind', 111])), + 'dict': {'property': 5}, + } + e.set_properties(properties) ec = e.to_client_entity() self.assertEqual(kc, ec.key) self.assertSetEqual(set(exclude_from_indexes), ec.exclude_from_indexes) self.assertEqual('kind', ec.kind) self.assertEqual(1234, ec.id) - self.assertEqual('kind2', ec['ref'].kind) - self.assertEqual(1235, ec['ref'].id) - self.assertEqual(self._PROJECT, ec['ref'].project) - - def testEntityFromClientEntity(self): Review comment: We don't need this test anymore ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 330686) Time Spent: 0.5h (was: 20m) > Python: Datastore: add support for embedded entities > ----------------------------------------------------- > > Key: BEAM-8405 > URL: https://issues.apache.org/jira/browse/BEAM-8405 > Project: Beam > Issue Type: Bug > Components: io-py-gcp > Reporter: Udi Meiri > Assignee: Udi Meiri > Priority: Major > Time Spent: 0.5h > Remaining Estimate: 0h > > The conversion methods to/from the client entity type should be updated to > support an embedded Entity. > https://github.com/apache/beam/blob/603d68aafe9bdcd124d28ad62ad36af01e7a7403/sdks/python/apache_beam/io/gcp/datastore/v1new/types.py#L216-L240 -- This message was sent by Atlassian Jira (v8.3.4#803005)