示例#1
0
 def test_build_from_key(self):
     entity_key = EntityKeyFactory().build(
         kind="Task",
         name=1,
     )
     task_key = TaskKey.build_from_key(key=entity_key)
     assert entity_key != task_key
     assert entity_key.key_literal() == task_key.key_literal()
 def _to_domain_entity(self, doc: datastore.Entity) -> Task:
     return Task(
         key=TaskKey.build_from_key(key=doc.key),
         name=TaskName(doc["name"]),
         project_key=ProjectKey.build_from_key(key=doc["project_key"])
         if doc["project_key"] is not None else doc["project_key"],
         finished_at=doc["finished_at"],
         created_at=doc["created_at"],
         updated_at=doc["update_at"],
     )
示例#3
0
 def _to_domain_entity(self, doc: DatastoreEntity) -> Task:
     model = TaskDataModel.from_datastore_entity(doc=doc)
     return Task(
         key=TaskKey.build_from_key(key=self.to_entity_key(datastore_key=model.key)),
         name=TaskName(model.name),
         project_key=ProjectKey.build_from_key(key=self.to_entity_key(datastore_key=model.project_key))
         if model.project_key is not None else model.project_key,
         finished_at=model.finished_at,
         created_at=model.created_at,
         updated_at=model.update_at,
     )