oship-dev team mailing list archive
-
oship-dev team
-
Mailing list archive
-
Message #01517
[Branch ~oship-dev/oship/devel] Rev 495: Implemented invariants for the Folder class and its tests. Bug #625626
------------------------------------------------------------
revno: 495
committer: Wagner Francisco Mezaroba <wagner@wagner-laptop>
branch nick: oship
timestamp: Mon 2010-09-27 10:13:22 -0300
message:
Implemented invariants for the Folder class and its tests. Bug #625626
added:
src/oship/openehr/rm/common/directory/tests/folder.py
modified:
src/oship/openehr/rm/common/change_control/__init__.py
src/oship/openehr/rm/common/directory/__init__.py
src/oship/openehr/rm/common/directory/interfaces.py
--
lp:oship
https://code.launchpad.net/~oship-dev/oship/devel
Your team OSHIP Development Team is subscribed to branch lp:oship.
To unsubscribe from this branch go to https://code.launchpad.net/~oship-dev/oship/devel/+edit-subscription
=== modified file 'src/oship/openehr/rm/common/change_control/__init__.py'
--- src/oship/openehr/rm/common/change_control/__init__.py 2010-09-17 19:11:05 +0000
+++ src/oship/openehr/rm/common/change_control/__init__.py 2010-09-27 13:13:22 +0000
@@ -38,7 +38,7 @@
def __init__(self, uid, preVid, data, lcstate, caudit, contribution, sig):
if uid.versionTreeId().isFirst() == (preVid!=None):
- raise ValueError(u'')
+ raise ValueError(u"If this is the first version it's not possible to have a preceding version uid and vice-versa.")
if contribution == None or contribution.type != 'CONTRIBUTION':
raise ValueError(u'Contribution must not be None and its type must be CONTRIBUTION')
self.uid=uid
=== modified file 'src/oship/openehr/rm/common/directory/__init__.py'
--- src/oship/openehr/rm/common/directory/__init__.py 2010-08-06 21:24:11 +0000
+++ src/oship/openehr/rm/common/directory/__init__.py 2010-09-27 13:13:22 +0000
@@ -15,7 +15,8 @@
grok.implements(IFolder)
def __init__(self, folders, items):
-
+ if folders is not None and len(folders) == 0:
+ raise ValueError(u'Folders /= Void implies not folders.is_empty')
self.folders=folders
self.items=items
=== modified file 'src/oship/openehr/rm/common/directory/interfaces.py'
--- src/oship/openehr/rm/common/directory/interfaces.py 2010-08-06 21:24:11 +0000
+++ src/oship/openehr/rm/common/directory/interfaces.py 2010-09-27 13:13:22 +0000
@@ -6,7 +6,6 @@
from zope.i18nmessageid import MessageFactory
from oship.openehr.rm.support.interfaces import IObjectRef
-
_ = MessageFactory('oship')
=== added file 'src/oship/openehr/rm/common/directory/tests/folder.py'
--- src/oship/openehr/rm/common/directory/tests/folder.py 1970-01-01 00:00:00 +0000
+++ src/oship/openehr/rm/common/directory/tests/folder.py 2010-09-27 13:13:22 +0000
@@ -0,0 +1,31 @@
+"""
+Do a Python test on the app.
+
+:Test-Layer: python
+"""
+import unittest
+import grok
+
+from oship.openehr.rm.common.directory import Folder, IFolder
+
+class FolderTest(unittest.TestCase):
+
+ def setUp(self):
+ self.emptyList = []
+ self.itemsList = []
+ self.notEmptyFolderList = [1,2,3]
+
+ def tearDown(self):
+ pass
+
+ def testShouldNotInitializeWithEmptyFolderList(self):
+ self.assertRaises(ValueError, Folder, self.emptyList, self.itemsList)
+
+ def testShouldInitializeWithNullFolderList(self):
+ f = Folder(None, self.itemsList)
+ self.assertEqual(None, f.folders)
+
+ def testShouldInitializeWithNotEmptyFolderList(self):
+ f = Folder(self.notEmptyFolderList, self.itemsList)
+ self.assertEqual(self.notEmptyFolderList, f.folders)
+