oship-dev team mailing list archive
-
oship-dev team
-
Mailing list archive
-
Message #01682
[Branch ~oship-dev/oship/devel] Rev 530: Test for the previous fix
------------------------------------------------------------
revno: 530
committer: Eduardo César
branch nick: local
timestamp: Mon 2011-01-03 16:34:29 -0200
message:
Test for the previous fix
added:
src/oship.openehr.rm/src/oship/openehr/rm/composition/content/entry/tests/instruction.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
=== added file 'src/oship.openehr.rm/src/oship/openehr/rm/composition/content/entry/tests/instruction.py'
--- src/oship.openehr.rm/src/oship/openehr/rm/composition/content/entry/tests/instruction.py 1970-01-01 00:00:00 +0000
+++ src/oship.openehr.rm/src/oship/openehr/rm/composition/content/entry/tests/instruction.py 2011-01-03 18:34:29 +0000
@@ -0,0 +1,105 @@
+"""
+Do a Python test on the app.
+
+:Test-Layer: python
+"""
+import unittest
+import grok
+
+from oship.openehr.rm.composition.content.entry import Instruction
+from oship.openehr.rm.datatypes.text import DvText
+
+
+
+
+
+
+from oship.openehr.rm.support.identification import LocatableRef, ObjectVersionId
+from oship.openehr.rm.data_structures.item_structure import ItemStructure
+
+from oship.openehr.rm.support.identification.interfaces import IObjectVersionId
+
+class StubVersion(object):
+ def __init__(self,uid, data=None):
+ self.uid = uid
+ self.data = data
+
+class FakeLocatable(object):
+ def __init__(self, node_id, parent=None, is_root=False):
+ self.node_id = node_id
+ self.parent = parent
+ self.is_root = is_root
+ self.items = []
+ def addSubItems(self, locatable):
+ items = self.items
+ items.append(locatable)
+ self.items = items
+ locatable.parent = self
+ def itemAtPath(self, path):
+ if path == "":
+ return self
+ nodes = path.split("/")
+ actual_node = path.split("/")[0]
+ for subitem in self.items:
+ if subitem.node_id == actual_node:
+ if len(nodes)>1:
+ for two_level_node in subitem.items:
+ if two_level_node.node_id == path.split("/")[1]:
+ return two_level_node
+ else:
+ return subitem
+ def pathExists(self,path):
+ if path == "":
+ return True
+ else:
+ nodes = path.split("/")
+ actual_node = path.split("/")[0]
+ for subitem in self.items:
+ if subitem.node_id == actual_node:
+ if len(nodes)>1:
+ for two_level_node in subitem.items:
+ if two_level_node.node_id == path.split("/")[1]:
+ return True
+ else:
+ return True
+ return False
+ def isArchetypeRoot(self):
+ return self.is_root
+ def pathOfItem(self,pathable):
+ if pathable == self:
+ return ""
+ if pathable in self.items:
+ return "/".join((pathable.node_id,))
+ for two_level_node in self.items:
+ if pathable in two_level_node.items:
+ return "/".join((two_level_node.node_id,pathable.node_id,))
+ return None
+
+class StubObjectId(object):
+ grok.implements(IObjectVersionId)
+ def __init__(self,value):
+ self.value = value
+
+
+class InstructionTest(unittest.TestCase):
+
+ def setUp(self):
+ self.narrative = DvText(u'A description',None,None,None,None,None)
+
+
+
+
+ a_version_identifier = StubObjectId(u"23123545::4324323442::32131213")
+ a_locatable_object = FakeLocatable(u'1234545',True)
+ a_version_object = StubVersion(a_version_identifier,a_locatable_object)
+ self.a_locatableRef = LocatableRef(a_version_object,a_locatable_object,namespace=u'local')
+ self.wf_details = ItemStructure(None,None,None,None,None,None,None)
+
+ def tearDown(self):
+ pass
+
+ def test_narrative_none(self):
+ self.assertRaises(ValueError, Instruction, None)
+
+ #def test_narrative_none(self):
+ # self.assertRaises(ValueError, Instruction, self.narrative)