r252660 - in collective.smartkeywordmanager/trunk: . collective/smartkeywordmanager

"Tom Gross" <svn-changes-z4DKO/[email protected]> Mon, 28 Oct 2013 21:55:41 +0000 (UTC)
Newsgroups gmane.comp.web.zope.plone.collective.cvs
Message-ID <[email protected]>
Author: tom_gross
Date: Mon Oct 28 21:55:40 2013
New Revision: 252660

Added:
   collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/testing.py
Removed:
   collective.smartkeywordmanager/trunk/setup.cfg
Modified:
   collective.smartkeywordmanager/trunk/   (props changed)
   collective.smartkeywordmanager/trunk/buildout.cfg
   collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/tests.py
   collective.smartkeywordmanager/trunk/setup.py
Log:
ported tests to plone.app.testing


Modified: collective.smartkeywordmanager/trunk/buildout.cfg
==============================================================================
--- collective.smartkeywordmanager/trunk/buildout.cfg	(original)
+++ collective.smartkeywordmanager/trunk/buildout.cfg	Mon Oct 28 21:55:40 2013
@@ -2,17 +2,19 @@
 extends =
     https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg
 package-name = collective.smartkeywordmanager
+package-extras = [test]
+parts += test-coverage zestreleaser
 
 [zestreleaser]
 recipe = zc.recipe.egg:scripts
 eggs =  
-   zest.releaser
-   Products.TinyMCE [test,docs]
+    zest.releaser
+    ${buildout:package-name} ${buildout:package-extras}
 
 [test-coverage]
 recipe = zc.recipe.testrunner
 eggs =
-    collective.smartkeywordmanager
+    ${buildout:package-name} ${buildout:package-extras}
     Pillow
 defaults = ['--coverage', '../../coverage', '-v', '--auto-progress', '-s', 'collective.smartkeywordmanager']
 

Added: collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/testing.py
==============================================================================
--- (empty file)
+++ collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/testing.py	Mon Oct 28 21:55:40 2013
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+import unittest2 as unittest
+
+from plone.app.testing import FunctionalTesting
+from plone.app.testing import IntegrationTesting
+from plone.app.testing import PLONE_FIXTURE
+from plone.app.testing import PloneSandboxLayer
+from plone.app.testing import login
+from plone.app.testing import setRoles
+from plone.app.testing import TEST_USER_ID
+from plone.app.testing import TEST_USER_NAME
+from plone.testing import z2
+
+
+
+class ProductLayer(PloneSandboxLayer):
+    defaultBases = (PLONE_FIXTURE,)
+
+    def setUpZope(self, app, configurationContext):
+        """Set up Zope."""
+        import collective.smartkeywordmanager
+        self.loadZCML(package=collective.smartkeywordmanager)
+        z2.installProduct(app, 'collective.smartkeywordmanager')
+
+    def setUpPloneSite(self, portal):
+        """Set up Plone."""
+        # Install into Plone site using portal_setup
+        self.applyProfile(portal, 'collective.smartkeywordmanager:default')
+
+    def tearDownZope(self, app):
+        """Tear down Zope."""
+        z2.uninstallProduct(app, 'collective.smartkeywordmanager')
+
+
+FIXTURE = ProductLayer()
+INTEGRATION_TESTING = IntegrationTesting(
+    bases=(FIXTURE,), name="CollectiveSmartkeywordmanagerLayer:Integration")
+FUNCTIONAL_TESTING = FunctionalTesting(
+    bases=(FIXTURE,), name="CollectiveSmartkeywordmanagerLayer:Functional")
+
+
+class BaseTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.portal = self.layer['portal']
+        self.app = self.layer['app']
+        setRoles(self.portal, TEST_USER_ID, ['Manager'])
+        login(self.portal, TEST_USER_NAME)
+
+
+class IntegrationTestCase(BaseTestCase):
+    """Base class for integration tests."""
+
+    layer = INTEGRATION_TESTING
+
+
+class FunctionalTestCase(BaseTestCase):
+    """Base class for functional tests."""
+
+    layer = FUNCTIONAL_TESTING

Modified: collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/tests.py
==============================================================================
--- collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/tests.py	(original)
+++ collective.smartkeywordmanager/trunk/collective/smartkeywordmanager/tests.py	Mon Oct 28 21:55:40 2013
@@ -1,42 +1,17 @@
-import unittest
+import unittest2
 
-#from zope.testing import doctestunit
-#from zope.component import testing
-from Testing import ZopeTestCase as ztc
-
-from Products.Five import fiveconfigure
-from Products.PloneTestCase import PloneTestCase as ptc
-from Products.PloneTestCase.layer import PloneSite
-ptc.setupPloneSite()
+from collective.smartkeywordmanager.testing import IntegrationTestCase
+from collective.smartkeywordmanager.views import smart_keyword_edit_form_view
 
 from zope.component import getUtility
 from plone.registry.interfaces import IRegistry
 from zope.publisher.browser import TestRequest
 
 
-import collective.smartkeywordmanager
-from collective.smartkeywordmanager.views import smart_keyword_edit_form_view
-
-
-class TestCase(ptc.PloneTestCase):
-
-    class layer(PloneSite):
-
-        @classmethod
-        def setUp(cls):
-            fiveconfigure.debug_mode = True
-            ztc.installPackage(collective.smartkeywordmanager)
-            fiveconfigure.debug_mode = False
-
-        @classmethod
-        def tearDown(cls):
-            pass
-
-
-class ProfileTestCase(TestCase):
+class ProfileTestCase(IntegrationTestCase):
 
     def test_action(self):
-        self.assertIn('edit_keywords', self.portal.portal_actions)
+        self.assertIn('edit_keywords', self.portal.portal_actions.object)
 
     def test_registry_batchsize(self):
         registry = getUtility(IRegistry)
@@ -47,42 +22,10 @@
         return self.assertEqual(registry['collective.smartkeywordmanager.separator'], ';')
 
 
-class ViewTestCase(TestCase):
-
+class ViewTestCase(IntegrationTestCase):
 
     def test_cook(self):
         request = TestRequest()
         view = smart_keyword_edit_form_view(self.portal, request)
-        print view.cook('abc')
-        print view.cook(['abc', 'foo'])
-
-        
-
-def test_suite():
-    return unittest.TestSuite([
-        unittest.makeSuite(ProfileTestCase),
-        unittest.makeSuite(ViewTestCase)
-
-        # Unit tests
-        #doctestunit.DocFileSuite(
-        #    'README.txt', package='collective.smartkeywordmanager',
-        #    setUp=testing.setUp, tearDown=testing.tearDown),
-
-        #doctestunit.DocTestSuite(
-        #    module='collective.smartkeywordmanager.mymodule',
-        #    setUp=testing.setUp, tearDown=testing.tearDown),
-
-
-        # Integration tests that use PloneTestCase
-        #ztc.ZopeDocFileSuite(
-        #    'README.txt', package='collective.smartkeywordmanager',
-        #    test_class=TestCase),
-
-        #ztc.FunctionalDocFileSuite(
-        #    'browser.txt', package='collective.smartkeywordmanager',
-        #    test_class=TestCase),
-
-        ])
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+        self.assertEqual(view.cook('abc'), ['abc'])
+        self.assertEqual(view.cook(['abc', 'xyz']), ['abc', 'xyz'])

Modified: collective.smartkeywordmanager/trunk/setup.py
==============================================================================
--- collective.smartkeywordmanager/trunk/setup.py	(original)
+++ collective.smartkeywordmanager/trunk/setup.py	Mon Oct 28 21:55:40 2013
@@ -27,6 +27,9 @@
           'setuptools',
           'plone.app.registry',
       ],
+      extras_require={
+        'test': ['plone.app.testing',
+                 'unittest2']},
       entry_points="""
       # -*- Entry points: -*-
 

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk