Skip to content
Browse files

cleanup testcode some more

  • Loading branch information...
1 parent 57a9235 commit 4aa0a1b63b5b9ba877b4bb3165d41342a78d396d @pjstevns committed
View
30 Products/ATVocabularyManager/tests/TODOtestVdexVocabulary.py
@@ -1,15 +1,12 @@
-import unittest
import os
-from Testing import ZopeTestCase
from Products.PloneTestCase import PloneTestCase
-
from Products.ATVocabularyManager.tests import PACKAGE_HOME
-
import common
VOCABTITLE = 'Test Vdex Vocabulary'
+
class TestVdexVocabulary(PloneTestCase.PloneTestCase):
def afterSetUp(self):
@@ -18,10 +15,9 @@ def afterSetUp(self):
def setupVdexVocabularyContainer(self):
self.loginAsPortalOwner()
- self.atvm.invokeFactory('VdexVocabulary','vdextest')
+ self.atvm.invokeFactory('VdexVocabulary', 'vdextest')
self.atvm.vdextest.setTitle(VOCABTITLE)
-
def setupVdexVocabulary(self):
self.setupVdexVocabularyContainer()
self.atvm.vdextest.invokeFactory('VdexTerm', 'key1')
@@ -32,13 +28,14 @@ def testGetVocabularyByName(self):
# Test if vocab can be fetched
self.setupVdexVocabulary()
vdextest = self.atvm.getVocabularyByName('vdextest')
- self.failUnlessEqual(vdextest.Title(),VOCABTITLE)
+ self.failUnlessEqual(vdextest.Title(), VOCABTITLE)
def testAddTerm(self):
self.setupVdexVocabularyContainer()
vdextest = self.atvm.vdextest
- vdextest.createTerm('foo',title='bar')
- self.failUnlessEqual(vdextest.getTermByKey('foo').getTermValue(), 'bar')
+ vdextest.createTerm('foo', title='bar')
+ self.failUnlessEqual(vdextest.getTermByKey('foo').getTermValue(),
+ 'bar')
def testGetVocabularyDict(self):
pass
@@ -55,8 +52,8 @@ def testShowLeafsOnly(self):
def testGetXMLBinding(self):
self.setupVdexVocabularyContainer()
vdextest = self.atvm.vdextest
- vdextest.createTerm('foo',title='bar')
- vdextest.createTerm('abc',title='123')
+ vdextest.createTerm('foo', title='bar')
+ vdextest.createTerm('abc', title='123')
sio = vdextest.exportXMLBinding()
# XXX: untested dump
@@ -73,13 +70,4 @@ def testSetXMLBinding(self):
# XXX: untested dump
#print sio.getvalue()
-
-
-def test_suite():
- from unittest import TestSuite, makeSuite
- suite = TestSuite()
- suite.addTest(makeSuite(TestVdexVocabulary))
- return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+#EOF
View
4 Products/ATVocabularyManager/tests/common.py
@@ -3,9 +3,9 @@
import Products.ATVocabularyManager
-from Products.ATVocabularyManager.config import *
+from Products.ATVocabularyManager.config import PROJECTNAME, TOOL_NAME
-from Products.Five import zcml
+from Zope2.App import zcml
from Products.Five import fiveconfigure
#from Products.PloneTestCase import PloneTestCase as ptc
View
31 Products/ATVocabularyManager/tests/testATVocabularyManager.py
@@ -1,22 +1,13 @@
#
# Test for TreeVocabulary
#
-import unittest
from time import sleep
-#from Testing import ZopeTestCase
from Products.PloneTestCase import PloneTestCase
-#from Products.Five import zcml
-
-import Products.ATVocabularyManager
-from Products.ATVocabularyManager.config import *
-
+from Products.ATVocabularyManager.config import PROJECTNAME
from Products.CMFCore.utils import getToolByName
-import common
-
-
class TestATVocabularyManager(PloneTestCase.PloneTestCase):
def afterSetUp(self):
@@ -44,7 +35,7 @@ def test_reinstall(self):
self.qi.installProduct(PROJECTNAME)
self.failUnless(self.qi.isProductInstalled(PROJECTNAME))
- sleep(1) # Else the ids are too similar and reinstall will fail. Oh well
+ sleep(1) # Else the ids are too similar and reinstall will fail.
#reinstallProducts
self.qi.reinstallProducts([PROJECTNAME, ])
self.failUnless(self.qi.isProductInstalled(PROJECTNAME))
@@ -73,8 +64,8 @@ def test_vocabulariesDeletedAtUninstall(self):
# XXX CMFQuickInstallerTool 3.0.3 does not delete the portal items any
# any longer if Folderish. Asked eleddy and jens what they think about
# the implications here(feature/bug) [do3cc]
- #self.assertRaises(AttributeError, getToolByName, self.portal, 'portal_vocabularies')
-
+ #self.assertRaises(AttributeError, getToolByName,
+ # self.portal, 'portal_vocabularies')
#install the product again
sleep(1)
@@ -88,7 +79,8 @@ def test_vocabulariesDeletedAtUninstall(self):
#self.failUnless(foo is None)
def test_zexpOfVocabulariesAtUninstall(self):
- """vocabulariees get deleted together with the tool at product uninstallation.
+ """vocabulariees get deleted together with the tool at product
+ uninstallation.
as a kind of safetybelt a zexp of all vocabularies gets created
when atvm gets uninstalled (in case this was done by accident)
@@ -103,7 +95,6 @@ def test_vocabulariesPreservedAtReinstall(self):
self.loginAsPortalOwner()
-
#install the product
self.qi.installProduct(PROJECTNAME)
@@ -117,7 +108,6 @@ def test_vocabulariesPreservedAtReinstall(self):
sleep(1)
self.qi.reinstallProducts([PROJECTNAME, ])
-
#the tool and the vocabularies are still there
atvm = getToolByName(self.portal, 'portal_vocabularies')
@@ -127,11 +117,4 @@ def test_vocabulariesPreservedAtReinstall(self):
self.assertEqual(foo.bar.Title(), 'Some test')
-def test_suite():
- from unittest import TestSuite, makeSuite
- suite = TestSuite()
- suite.addTest(makeSuite(TestATVocabularyManager))
- return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+#EOF
View
3 Products/ATVocabularyManager/tests/testSimpleVocabulary.py
@@ -239,5 +239,4 @@ def test_suite():
return suite
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+#EOF
View
38 Products/ATVocabularyManager/tests/testTreeVocabulary.py
@@ -4,14 +4,10 @@
import unittest
-#from Testing import ZopeTestCase
from Products.PloneTestCase import PloneTestCase
-
from Products.ATVocabularyManager.utils.vocabs import createHierarchicalVocabs
-
from Products.CMFCore.utils import getToolByName
-
import common
@@ -55,7 +51,8 @@ def test_getTermKeyPath(self):
correctPath = [autUID, tyrUID, aussUID]
path = vocab.aut.tyr.auss.getTermKeyPath()
- self.assertEqual(correctPath, path, "getTermKeyPath does not return the correct path")
+ self.assertEqual(correctPath, path,
+ "getTermKeyPath does not return the correct path")
def testTranslation(self):
"""tests if treevocabulary works fine with linguaplone
@@ -74,26 +71,29 @@ def testTranslation(self):
langtool = getToolByName(self.portal, 'portal_languages')
# set available portal languages
- langtool.supported_langs=['en', 'de']
+ langtool.supported_langs = ['en', 'de']
# per default english is the preferred language
self.assertEqual('en', langtool.getPreferredLanguage())
enDict = vocab.getVocabularyDict()
- autUID=vocab.aut.UID()
+ autUID = vocab.aut.UID()
# title for austria in english
self.assertEqual('Austria', enDict[autUID][0])
-
# switch to german
- vocab.REQUEST['set_language']='de'
+ vocab.REQUEST['set_language'] = 'de'
langtool.setLanguageBindings()
self.assertEqual('de', langtool.getPreferredLanguage())
deDict = vocab.getVocabularyDict()
- self.assertEqual('Oesterreich', deDict[autUID][0], "Vocab Title is not translated")
+ self.assertEqual(
+ 'Oesterreich', deDict[autUID][0],
+ "Vocab Title is not translated")
# for not translated content, the canonicals title is used
germanyUID = vocab.ger.UID()
- self.assertEqual('Germany', deDict[germanyUID][0], "Canonical's is not used for unstranslated vocabularies")
+ self.assertEqual(
+ 'Germany', deDict[germanyUID][0],
+ "Canonical's is not used for unstranslated vocabularies")
def _translateVocabulary(self):
"""translates the vocabulary 'regions'
@@ -104,12 +104,13 @@ def _translateVocabulary(self):
qi = getToolByName(self.portal, 'portal_quickinstaller')
lpAvailable = qi.isProductAvailable('LinguaPlone')
- self.failUnless(lpAvailable, "Product LinguaPlone has to be available in INSTANCE_HOME")
+ self.failUnless(
+ lpAvailable,
+ "Product LinguaPlone has to be available in INSTANCE_HOME")
if not qi.isProductInstalled('LinguaPlone'):
qi.installProduct('LinguaPlone')
-
regions = self.atvm.getVocabularyByName('regions')
regions.aut.setLanguage('en')
regions.aut.addTranslation('de', title='Oesterreich')
@@ -119,13 +120,4 @@ def _translateVocabulary(self):
# we do not completely translate the vocabulary, to see if canonical
# titles are correctly used as fallbacks
-
-def test_suite():
- from unittest import TestSuite, makeSuite
- suite = TestSuite()
- suite.addTest(makeSuite(TestTreeVocabulary))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+#EOF
View
14 Products/ATVocabularyManager/tests/test_doctest.py
@@ -3,17 +3,10 @@
__author__ = """Harald Friessnegger <harald at webmeisterei(dot) com>"""
__docformat__ = 'plaintext'
-
-import unittest
import doctest
from Products.PloneTestCase import PloneTestCase
-
-#from Products.CMFCore.utils import getToolByName
-
import common
-from Products.ATVocabularyManager import doc
-
class TestSearchTreeVocabulary(PloneTestCase.PloneTestCase):
"""
@@ -48,9 +41,4 @@ def test_suite():
))
return TestSuite(suites)
-
-##code-section module-footer #fill in your manual code here
-##/code-section module-footer
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+#EOF

0 comments on commit 4aa0a1b

Please sign in to comment.
Something went wrong with that request. Please try again.