r13537 - in ArchGenXML/trunk/src/archgenxml: . templates templates/tests
"Philipp Auersperg" <[email protected]> Tue, 29 Mar 2011 08:02:14 +0000
| Newsgroups | gmane.comp.web.zope.plone.archetypes.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: zworkb
Date: Tue Mar 29 08:02:13 2011
New Revision: 13537
Added:
ArchGenXML/trunk/src/archgenxml/templates/tests/FuncDocTestcase.pydtml
Modified:
ArchGenXML/trunk/src/archgenxml/ArchetypesGenerator.py
ArchGenXML/trunk/src/archgenxml/atumlprofile.py
ArchGenXML/trunk/src/archgenxml/templates/field.pydtml
ArchGenXML/trunk/src/archgenxml/templates/tests/DocTestcase.pydtml
ArchGenXML/trunk/src/archgenxml/templates/tests/PloneFunctionalTestcase.pydtml
Log:
functional tests
Modified: ArchGenXML/trunk/src/archgenxml/ArchetypesGenerator.py
==============================================================================
--- ArchGenXML/trunk/src/archgenxml/ArchetypesGenerator.py (original)
+++ ArchGenXML/trunk/src/archgenxml/ArchetypesGenerator.py Tue Mar 29 08:02:13 2011
@@ -557,7 +557,10 @@
# set attributes from tgv
for k in tgv.keys():
- if k not in noparams and not k.startswith('widget:'):
+ if not k:
+ log.warn(u"Empty tagged value name for tag '%s' in field '%s'.",
+ k, element.getName())
+ if k and k not in noparams and not k.startswith('widget:'):
v = tgv[k]
if v is None:
log.warn(u"Empty tagged value for tag '%s' in field '%s'.",
@@ -816,6 +819,10 @@
# ATVocabularyManager: Add NamedVocabulary to field.
vocaboptions = {}
for t in attr.getTaggedValues().items():
+ if not t[0]:
+ log.warn(u"Empty tagged value name for tag '%s' in field '%s'.",
+ t, element.getName())
+
if t[0].startswith('vocabulary:'):
vocaboptions[t[0][11:]] = t[1]
if vocaboptions:
@@ -1345,7 +1352,6 @@
# @param template The template file to use in generating the output.
def generateBaseFunctionalTestcaseClass(self,element,template):
log.debug('write testFunctional.py, only if needed.')
-
if not os.path.exists(os.path.join(self.targetRoot,
element.getPackage().getFilePath(),
'testFunctional.py')):
Modified: ArchGenXML/trunk/src/archgenxml/atumlprofile.py
==============================================================================
--- ArchGenXML/trunk/src/archgenxml/atumlprofile.py (original)
+++ ArchGenXML/trunk/src/archgenxml/atumlprofile.py Tue Mar 29 08:02:13 2011
@@ -90,7 +90,7 @@
at_uml_profile.addStereoType(
'functional_doc_testcase', ['XMIClass'],
dispatching=1,
- template='tests/DocTestcase.pydtml',
+ template='tests/FuncDocTestcase.pydtml',
generator='generateDocTestcaseClass',
description='Turns a class into a functional doctest class. It must subclass a '
"'<<plone_testcase>>'.")
Modified: ArchGenXML/trunk/src/archgenxml/templates/field.pydtml
==============================================================================
--- ArchGenXML/trunk/src/archgenxml/templates/field.pydtml (original)
+++ ArchGenXML/trunk/src/archgenxml/templates/field.pydtml Tue Mar 29 08:02:13 2011
@@ -27,9 +27,9 @@
</dtml-if>
<dtml-if "parentname=='CompoundField'">
from Products.CompoundField.CompoundField import CompoundField
+</dtml-if>
######<dtml-var parentname>
<dtml-var "generator.generateArcheSchema(klass, generator.getLocalFieldSpecs(klass))" >
-</dtml-if>
class <dtml-var "klass.getCleanName()">(<dtml-if "klass.getGenParents()"><dtml-var "', '.join([p.getCleanName() for p in klass.getGenParents()])"><dtml-else><dtml-var parentname></dtml-if>):
@@ -64,7 +64,6 @@
security.declarePrivate('set')
security.declarePrivate('get')
-
<dtml-if "not parsed_class">
def get(self, instance, **kwargs):
return <dtml-var parentname>.get(self, instance, **kwargs)
Modified: ArchGenXML/trunk/src/archgenxml/templates/tests/DocTestcase.pydtml
==============================================================================
--- ArchGenXML/trunk/src/archgenxml/templates/tests/DocTestcase.pydtml (original)
+++ ArchGenXML/trunk/src/archgenxml/templates/tests/DocTestcase.pydtml Tue Mar 29 08:02:13 2011
@@ -35,7 +35,7 @@
def afterSetUp(self):
"""
"""
- pass
+ <dtml-if parent><dtml-var "parent.getCleanName()">.afterSetUp(self)<dtml-else>pass</dtml-if>
<dtml-else>
<dtml-var "parsed_class.methods['afterSetUp'].getSrc()"></dtml-if>
Added: ArchGenXML/trunk/src/archgenxml/templates/tests/FuncDocTestcase.pydtml
==============================================================================
--- (empty file)
+++ ArchGenXML/trunk/src/archgenxml/templates/tests/FuncDocTestcase.pydtml Tue Mar 29 08:02:13 2011
@@ -0,0 +1,128 @@
+import os, sys
+from Products.PloneTestCase import PloneTestCase
+
+try:
+ from Products.PloneTestCase.PloneTestCase import USELAYER
+ from Products.PloneTestCase.layer import PloneSite
+except:
+ USELAYER = False
+if __name__ == '__main__':
+ execfile(os.path.join(sys.path[0], 'framework.py'))
+
+<dtml-var "generator.getProtectedSection(parsed_class, 'module-header')">
+#
+# Test-cases for class(es) <dtml-var "', '.join([p.getName() for p in klass.getRealizationParents()])">
+#
+
+from Testing import ZopeTestCase
+from Products.Five.testbrowser import Browser
+<dtml-if "parent is not None">
+from <dtml-var "parent.getQualifiedModuleName(None,forcePluginRoot=1)"> import <dtml-var "parent.getCleanName()">
+<dtml-else>
+from Products.PloneTestCase.PloneTestCase import PloneTestCase
+</dtml-if>
+
+# Import the tested classes
+<dtml-in "klass.getRealizationParents() + klass.getClientDependencyClasses(includeParents=True)">
+from <dtml-var "_['sequence-item'].getQualifiedModuleName(None, forcePluginRoot=1)"> import <dtml-var "_['sequence-item'].getCleanName()">
+</dtml-in>
+
+
+class <dtml-var "klass.getCleanName()"><dtml-if parent>(PloneTestCase.FunctionalTestCase,<dtml-var "parent.getCleanName()">)<dtml-else>(PloneTestCase.FunctionalTestCase)</dtml-if>:
+<dtml-if "parsed_class and parsed_class.getDocumentation()"> """<dtml-var "parsed_class.getDocumentation()">"""
+<dtml-else> """Test-cases for class(es) <dtml-var "', '.join([p.getName() for p in klass.getRealizationParents()])">."""
+</dtml-if>
+
+<dtml-var "generator.getProtectedSection(parsed_class, 'class-header_'+klass.getCleanName(), 1)">
+<dtml-if "not parsed_class or 'afterSetUp' not in parsed_class.methods.keys()">
+ def afterSetUp(self):
+ """
+ """
+ PloneTestCase.FunctionalTestCase.afterSetUp(self)
+ <dtml-if parent><dtml-var "parent.getCleanName()">.afterSetUp(self)<dtml-else>pass</dtml-if>
+
+ self.browser = Browser()
+
+<dtml-else>
+<dtml-var "parsed_class.methods['afterSetUp'].getSrc()"></dtml-if>
+
+<dtml-if "not parsed_class or 'getError' not in parsed_class.methods.keys()">
+ def getError(self, error_index=0):
+ """
+ Error access utility method.
+
+ Get the error msg as text, by default the last one.
+ @param self The object pointer.
+ @param error_index The index of the error of interest. If not passed in,
+ an index of 0 is used.
+ """
+ error_log = self.portal.error_log
+ try:
+ id = error_log.getLogEntries()[0]['id']
+ except IndexError:
+ # no errors
+ return ''
+ else:
+ return error_log.getLogEntryAsText(id)
+</dtml-if>
+
+<dtml-if "not parsed_class or 'printError' not in parsed_class.methods.keys()">
+ def printError(self, error_index=0):
+ """
+ Error printing utility method.
+
+ Prints an error. Useful for debugging sessions. By default, the
+ last error is printed.
+
+ @param self The object pointer.
+ @param error_index The index of the error of interest. If not passed in,
+ an index of 0 is used.
+ """
+ print '='*70
+ print self.get_error(error_index)
+ print '-'*70
+</dtml-if>
+
+<dtml-if "not parsed_class or 'Session' not in parsed_class.methods.keys()">
+ class Session(dict):
+ def set(self, key, value):
+ self[key] = value
+
+</dtml-if>
+
+<dtml-if "not parsed_class or '_setup' not in parsed_class.methods.keys()">
+ def _setup(self):
+ PloneTestCase.FunctionalTestCase._setup(self)
+ self.app.REQUEST['SESSION'] = self.Session()
+</dtml-if>
+
+ # Manually created methods
+<dtml-if parsed_class>
+<dtml-in "parsed_class.methods.values()">
+<dtml-let allmethodnames="[m.testmethodName() for m in generator.getMethodsToGenerate(klass)[0]]">
+<dtml-if "_['sequence-item'].getName() not in allmethodnames+['afterSetUp']">
+<dtml-var "_['sequence-item'].getSrc()">
+</dtml-if>
+</dtml-let>
+</dtml-in>
+</dtml-if>
+
+
+def test_suite():
+ from unittest import TestSuite
+ from Testing.ZopeTestCase.zopedoctest import ZopeDocFileSuite
+ from Testing.ZopeTestCase import <dtml-if "klass.hasStereoType('functional_doc_testcase')">FunctionalDocFileSuite<dtml-else>ZopeDocFileSuite</dtml-if>
+
+ <dtml-var "generator.getProtectedSection(parsed_class, 'test-suite-in-between')">
+
+ s = <dtml-if "klass.hasStereoType('functional_doc_testcase')">FunctionalDocFileSuite<dtml-else>ZopeDocFileSuite</dtml-if>('<dtml-var "testname">.txt',
+ package='Products.<dtml-var "klass.getPackage().getProduct().getCleanName()">.doc',
+ test_class=<dtml-var "klass.getCleanName()">)
+ if USELAYER:
+ s.layer = PloneSite
+ return TestSuite((s,
+ ))
+
+<dtml-var "generator.getProtectedSection(parsed_class, 'module-footer')">
+if __name__ == '__main__':
+ framework()
Modified: ArchGenXML/trunk/src/archgenxml/templates/tests/PloneFunctionalTestcase.pydtml
==============================================================================
--- ArchGenXML/trunk/src/archgenxml/templates/tests/PloneFunctionalTestcase.pydtml (original)
+++ ArchGenXML/trunk/src/archgenxml/templates/tests/PloneFunctionalTestcase.pydtml Tue Mar 29 08:02:13 2011
@@ -9,6 +9,7 @@
from Testing import ZopeTestCase
from Products.Five.testbrowser import Browser
from Products.PloneTestCase import PloneTestCase
+
<dtml-if taggedImports><dtml-var taggedImports></dtml-if>
<dtml-if dependentImports><dtml-var dependentImports></dtml-if>
<dtml-if additionalImports><dtml-var additionalImports></dtml-if>
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar