Permalink
Browse files

Tests. Currently broken :(

  • Loading branch information...
1 parent d13754e commit ca4f67bdff7d1d6bdf6762e8faefde562bfd788b @simonedeponti simonedeponti committed Dec 15, 2012
View
@@ -43,7 +43,8 @@
],
extras_require={
'test': [
- 'plone.app.testing',
+ 'mock',
+ 'plone.app.testing'
],
},
entry_points="""
@@ -1,19 +1,50 @@
# -*- coding: utf-8 -*-
-from plone.app.testing import PloneWithPackageLayer
+from decimal import Decimal
+from plone.app.testing import PLONE_FIXTURE
+from plone.app.testing import PloneSandboxLayer
from plone.app.testing import IntegrationTesting
+from plone.app.testing import FunctionalTesting
+from plone.app.testing import TEST_USER_ID
+from plone.app.testing import TEST_USER_NAME
+from plone.app.testing import login
+from plone.app.testing import setRoles
-import collective.simplemanagement
+class BaseLayer(PloneSandboxLayer):
-SIMPLEMANAGEMENT = PloneWithPackageLayer(
- zcml_package=collective.simplemanagement,
- zcml_filename='testing.zcml',
- gs_profile_id='collective.simplemanagement:default',
- name="SIMPLEMANAGEMENT"
+ defaultBases = (PLONE_FIXTURE,)
+
+ def setUpZope(self, app, configurationContext): # pylint: disable=W0613
+ # Load ZCML
+ import collective.simplemanagement
+ self.loadZCML(package=collective.simplemanagement, name='testing.zcml')
+
+ def setUpPloneSite(self, portal):
+ # Install into Plone site using portal_setup
+ self.applyProfile(portal, 'collective.simplemanagement:default')
+ setRoles(portal, TEST_USER_ID, ['Manager'])
+ login(portal, TEST_USER_NAME)
+ portal.invokeFactory('Project', 'test-project', title=u"Test project")
+ test_project = portal['test-project']
+ stories = []
+ for i in xrange(1, 4):
+ test_project.invokeFactory('Story', 'test-story-%d' % i,
+ title=(u"Test story %d" % i))
+ stories.append(test_project['test-story-%d' % i])
+ stories[-1].estimate = Decimal(10*i)
+ setRoles(portal, TEST_USER_ID, ['Member'])
+
+
+BASE = BaseLayer()
+
+
+BASE_INTEGRATION_TESTING = IntegrationTesting(
+ bases=(BASE,),
+ name="collective.simplemanagement base integration testing"
)
-SIMPLEMANAGEMENT_INTEGRATION = IntegrationTesting(
- bases=(SIMPLEMANAGEMENT,),
- name="SIMPLEMANAGEMENT_INTEGRATION"
+BASE_FUNCTIONAL_TESTING = FunctionalTesting(
+ bases=(BASE,),
+ name="collective.simplemanagement base functional testing"
)
@@ -0,0 +1 @@
+#
@@ -0,0 +1,103 @@
+from datetime import datetime
+import unittest2 as unittest
+
+from mock import patch
+
+from ..interfaces import ITimeline
+from ..timeline import BaseTimeline
+from ..testing import BASE_INTEGRATION_TESTING
+
+
+class DummyTimeline(BaseTimeline):
+
+ indexes = ('a', 'b')
+
+ def index(self, indexes, previous):
+ return {
+ k: previous.get(k, 0) + 1 for k in indexes
+ }
+
+
+class TestTimeline(unittest.TestCase):
+
+ @patch('collective.simplemanagement.timeline.datetime', autospec=True)
+ def test_snapshot_full(self, mock_datetime):
+ now = datetime(2012, 12, 15, 0, 0, 0)
+ mock_datetime.now.return_value = now
+ timeline = DummyTimeline()
+ self.assertNotIn('a', timeline.data)
+ self.assertNotIn('b', timeline.data)
+ timeline.snapshot()
+ self.assertIn('a', timeline.data)
+ self.assertIn('b', timeline.data)
+ self.assertEqual(
+ tuple(timeline.data['a'].items()),
+ ((now, 1),)
+ )
+ self.assertEqual(
+ tuple(timeline.data['b'].items()),
+ ((now, 1),)
+ )
+ before = now
+ now = datetime(2012, 12, 16, 0, 0, 0)
+ mock_datetime.now.return_value = now
+ timeline.snapshot()
+ self.assertEqual(
+ tuple(timeline.data['a'].items()),
+ ((before, 1), (now, 2))
+ )
+ self.assertEqual(
+ tuple(timeline.data['b'].items()),
+ ((before, 1), (now, 2))
+ )
+
+ def test_snapshot_partial(self):
+ pass
+
+ def test_snapshot_noinsert(self):
+ pass
+
+ def test_slice(self):
+ pass
+
+
+class TestIteration(unittest.TestCase):
+
+ layer = BASE_INTEGRATION_TESTING
+
+ def test_create_iteration(self):
+ pass
+
+ def test_update_iteration(self):
+ pass
+
+ def test_add_story(self):
+ pass
+
+ def test_update_story(self):
+ pass
+
+ def test_delete_story(self):
+ pass
+
+ def test_move_in_story(self):
+ pass
+
+ def test_move_out_story(self):
+ pass
+
+ def test_add_booking(self):
+ pass
+
+ def test_update_booking(self):
+ pass
+
+ def test_remove_booking(self):
+ pass
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestTimeline))
+ suite.addTest(unittest.makeSuite(TestIteration))
+ return suite

0 comments on commit ca4f67b

Please sign in to comment.