oship-dev team mailing list archive
-
oship-dev team
-
Mailing list archive
-
Message #01404
[Branch ~oship-dev/oship/devel] Rev 474: Implemented hasRowWithKeys and rowWithKeys methods and their tests. Bug #607524
------------------------------------------------------------
revno: 474
committer: Wagner Francisco Mezaroba <wagner@wagner-laptop>
branch nick: oship
timestamp: Thu 2010-08-26 11:23:50 -0300
message:
Implemented hasRowWithKeys and rowWithKeys methods and their tests. Bug #607524
modified:
src/oship/openehr/rm/data_structures/item_structure/__init__.py
src/oship/openehr/rm/data_structures/item_structure/tests/item_structure.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/data_structures/item_structure/__init__.py'
--- src/oship/openehr/rm/data_structures/item_structure/__init__.py 2010-08-18 13:36:39 +0000
+++ src/oship/openehr/rm/data_structures/item_structure/__init__.py 2010-08-26 14:23:50 +0000
@@ -138,12 +138,23 @@
return row
def hasRowWithKeys(self,keys):
- u"""Return True if a row's first n columns contain the names of set of
- keys."""
+ keysSize = len(keys)
+ for row in self.rows:
+ nFirstColumns = row.items[:keysSize]
+ nFirstColumnsName = [column.name.value for column in nFirstColumns]
+ if nFirstColumnsName == keys:
+ return True
+ return False
def rowWithKeys(self,keys):
- u"""Return the row whose first n columns contain the names in the set
- of keys."""
+ keysSize = len(keys)
+ for row in self.rows:
+ nFirstColumns = row.items[:keysSize]
+ nFirstColumnsName = [column.name.value for column in nFirstColumns]
+ if nFirstColumnsName == keys:
+ return row
+ return None
+
def elementAtCell(self,i, j):
if i < 0 or j < 0:
=== modified file 'src/oship/openehr/rm/data_structures/item_structure/tests/item_structure.py'
--- src/oship/openehr/rm/data_structures/item_structure/tests/item_structure.py 2010-08-18 13:36:39 +0000
+++ src/oship/openehr/rm/data_structures/item_structure/tests/item_structure.py 2010-08-26 14:23:50 +0000
@@ -243,3 +243,35 @@
for item in self.itemsCluster3:
self.assertEqual( item, self.aTable.elementAtNamedCell(self.element1Cluster3Name.value, item.name.value))
+ def testHasRowWithExistentKeysCluster1(self):
+ keys = [self.element1Cluster1Name.value]
+ self.assertTrue(self.aTable.hasRowWithKeys(keys))
+
+ def testHasRowWithExistentKeysCluster2(self):
+ keys = [self.element1Cluster2Name.value, self.element2Cluster2Name.value]
+ self.assertTrue(self.aTable.hasRowWithKeys(keys))
+
+ def testHasRowWithExistentKeysCluster3(self):
+ keys = [self.element1Cluster3Name.value, self.element2Cluster3Name.value, self.element3Cluster3Name.value]
+ self.assertTrue(self.aTable.hasRowWithKeys(keys))
+
+ def testHasRowWithInexistentKeys(self):
+ keys = ['inexistent key']
+ self.assertFalse(self.aTable.hasRowWithKeys(keys))
+
+ def testRowWithExistentKeysCluster1(self):
+ keys = [self.element1Cluster1Name.value]
+ self.assertEquals(self.cluster1, self.aTable.rowWithKeys(keys))
+
+ def testRowWithExistentKeysCluster2(self):
+ keys = [self.element1Cluster2Name.value, self.element2Cluster2Name.value]
+ self.assertEquals(self.cluster2, self.aTable.rowWithKeys(keys))
+
+ def testRowWithExistentKeysCluster3(self):
+ keys = [self.element1Cluster3Name.value, self.element2Cluster3Name.value, self.element3Cluster3Name.value]
+ self.assertEquals(self.cluster3, self.aTable.rowWithKeys(keys))
+
+ def testRowWithInexistentKeys(self):
+ keys = ['inexistent key']
+ self.assertEquals(None, self.aTable.rowWithKeys(keys))
+