def test_dao_get_by_uid_returns_matching_dtos_sorted_by_id(self): different_uid = models.ContentChunkDAO.make_uid( 'other', self.resource_id) first_key = models.ContentChunkEntity( content_type=self.content_type, contents=self.contents, supports_custom_tags=self.supports_custom_tags, uid=self.uid).put() second_key = models.ContentChunkEntity( content_type=self.content_type, contents=self.contents + '2', supports_custom_tags=self.supports_custom_tags, uid=self.uid).put() unused_different_uid_key = models.ContentChunkEntity( content_type=self.content_type, contents=self.contents, supports_custom_tags=self.supports_custom_tags, uid=different_uid).put() expected_dtos = [ models.ContentChunkDAO.get(first_key.id()), models.ContentChunkDAO.get(second_key.id()) ] actual_dtos = models.ContentChunkDAO.get_by_uid(self.uid) self.assert_list_fuzzy_equal(expected_dtos, actual_dtos)
def test_dao_make_dto(self): key = models.ContentChunkEntity( content_type=self.content_type, contents=self.contents, supports_custom_tags=self.supports_custom_tags, uid=self.uid).put() entity = db.get(key) # Refetch to avoid timestamp skew. dto = models.ContentChunkDAO._make_dto(entity) self.assertEqual(entity.content_type, dto.content_type) self.assertEqual(entity.contents, dto.contents) self.assertEqual(entity.key().id(), dto.id) self.assertEqual(entity.last_modified, dto.last_modified) self.assertEqual(entity.supports_custom_tags, dto.supports_custom_tags) entity_type_id, entity_resource_id = models.ContentChunkDAO._split_uid( entity.uid) self.assertEqual(entity_resource_id, dto.resource_id) self.assertEqual(entity_type_id, dto.type_id)