Commit 54e326c5 authored by Jérome Perrin's avatar Jérome Perrin

ERP5: "quick and dirty" type annotations XXX

IIRC the only thing needed is that ERP5TypeTestCase.getPortal is an
ERP5Site
parent c7a8ec5f
...@@ -53,6 +53,11 @@ from Products.ERP5Type.Utils import sortValueList ...@@ -53,6 +53,11 @@ from Products.ERP5Type.Utils import sortValueList
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Accessor import Base as BaseAccessor from Products.ERP5Type.Accessor import Base as BaseAccessor
try:
from typing import List
except ImportError:
pass
try: try:
from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
except ImportError: except ImportError:
...@@ -202,6 +207,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -202,6 +207,7 @@ class FolderMixIn(ExtensionClass.Base):
security.declarePublic('newContent') security.declarePublic('newContent')
def newContent(self, id=None, portal_type=None, id_group=None, def newContent(self, id=None, portal_type=None, id_group=None,
default=None, method=None, container=None, temp_object=0, **kw): default=None, method=None, container=None, temp_object=0, **kw):
# type: (...) -> Folder
"""Creates a new content. """Creates a new content.
This method is public, since TypeInformation.constructInstance will perform This method is public, since TypeInformation.constructInstance will perform
the security check. the security check.
...@@ -417,6 +423,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -417,6 +423,7 @@ class FolderMixIn(ExtensionClass.Base):
# Get the content # Get the content
security.declareProtected(Permissions.AccessContentsInformation, 'searchFolder') security.declareProtected(Permissions.AccessContentsInformation, 'searchFolder')
def searchFolder(self, **kw): def searchFolder(self, **kw):
# type: (str) -> List[Folder]
""" """
Search the content of a folder by calling Search the content of a folder by calling
the portal_catalog. the portal_catalog.
...@@ -1513,6 +1520,7 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr ...@@ -1513,6 +1520,7 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
def objectValues(self, spec=None, meta_type=None, portal_type=None, def objectValues(self, spec=None, meta_type=None, portal_type=None,
sort_on=None, sort_order=None, checked_permission=None, sort_on=None, sort_order=None, checked_permission=None,
**kw): **kw):
# type: () -> List[Folder]
# Returns list of objects contained in this folder. # Returns list of objects contained in this folder.
# (no docstring to prevent publishing) # (no docstring to prevent publishing)
if meta_type is not None: if meta_type is not None:
...@@ -1545,6 +1553,7 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr ...@@ -1545,6 +1553,7 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'contentValues' ) 'contentValues' )
def contentValues(self, *args, **kw): def contentValues(self, *args, **kw):
# type: () -> List[Folder]
# Returns a list of documents contained in this folder. # Returns a list of documents contained in this folder.
# ( no docstring to prevent publishing ) # ( no docstring to prevent publishing )
portal_type_id_list = self._getTypesTool().listContentTypes() portal_type_id_list = self._getTypesTool().listContentTypes()
......
...@@ -214,6 +214,13 @@ def _parse_args(self, *args, **kw): ...@@ -214,6 +214,13 @@ def _parse_args(self, *args, **kw):
_parse_args._original = DateTime._original_parse_args _parse_args._original = DateTime._original_parse_args
DateTime._parse_args = _parse_args DateTime._parse_args = _parse_args
try:
from erp5.portal_type import ERP5Site as erp5_portal_type_ERP5Site
except ImportError:
pass
class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
"""Mixin class for ERP5 based tests. """Mixin class for ERP5 based tests.
""" """
...@@ -997,6 +1004,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): ...@@ -997,6 +1004,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
return portal_name + '_' + m.hexdigest() return portal_name + '_' + m.hexdigest()
def getPortal(self): def getPortal(self):
# type: () -> erp5_portal_type_ERP5Site
"""Returns the portal object, i.e. the "fixture root". """Returns the portal object, i.e. the "fixture root".
It also does some initialization, as if the portal was accessed for the It also does some initialization, as if the portal was accessed for the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment