Source

psilib / test_som.py

Diff from to

test_som.py

+'''Library for PSI maps'''
+
+__title__ = 'test_som'
+__version__ = '0.03-test'
+__author__  = 'L. C. Rees (xanimal@users.sf.net)'
+
+'''Tests SOM functionality in a structured way'''
+
 from som import *
 
 def testSom():
     '''Test if all of SOM is functioning properly'''
-    d = Root()
-    p = Psi()
-    e = Collection('test', 'test', 'test')
-    p.appendChild(e)
-    e.addFilter('test', 'test', 'test')
-    e.filters[0].addAction('read', 'test', 'test')
-    e.filters[0].addAccess('grant', 'test', 'test')
-    e.filters[0].addSort('par', 'test')
-    e.filters[0].acl[0].addRight('read')
-    e.filters[0].actions[0].addIf('test', 'test')
-    e.filters[0].actions[0].setTime('day','5', '10', '11', '5')
-    e.filters[0].addVersion('archive', 'seq')
-    e.filters[0].setTime('week')
-    e.filters[0].versions[0].addChange('name', 'test')
-    e.addCollection('test2', 'thing', 'stuff')
-    e.addField('thing')
-    e.addResource('thing', 'thing', 'thing')
-    e.addFilter('thing', 'thing')
-    e.addCollection('thing3')
-    e.addLink('test')
-    e.addInclude('thing')
-    e.addResource('test')
-    e.resources[0].addResult('test')
-    e.resources[0].setMetadata('planned')
-    e.resources[0].metadata.addLog('read', 'planned', '10', '20', 'dude', 'test')
-    e.resources[0].addFragment('test')
-    e.resources[0].addText('some', 'some', 'some', 'preserve', 'some')
-    e.resources[0].addException('test')
-    e.resources[0].addParameter('test')
-    e.resources[0].addResult('test2')
-    e.resources[0].addFilter('test')
-    e.resources[0].filters[0].addAccess('grant', 'ssl', 'dude')
-    e.resources[0].filters[0].acl[0].addRight('read')
-    e.resources[0].addLink('something')
-    e.resources[0].addParameter('test2')
-    e.resources[0].addField('test')
-    e.resources[0].addFragment('test2')
-    e.resources[0].addField('something')
-    e.resources[0].addException('thing', 'thing', 'thing')
-    e.resources[0].addInclude('test')
-    e.resources[0].addResult('test3')
-    e.setMetadata()
-    e.addCollection('test3')
-    d.appendChild(p)
-    print d       
+    test = Collection('test', 'test', 'test')
+    test.addFilter('test', 'test', 'test')
+    test.filters[0].addAction('read', 'test', 'test')
+    test.filters[0].addAccess('grant', 'test', 'test')
+    test.filters[0].addSort('par', 'test')
+    test.filters[0].acl[0].addRight('read')
+    test.filters[0].actions[0].addIf('test', 'test')
+    test.filters[0].actions[0].setTime('day','5', '10', '11', '5')
+    test.filters[0].addVersion('archive', 'seq')
+    test.filters[0].setTime('week')
+    test.filters[0].versions[0].addChange('name', 'test')
+    test.addCollection('test2', 'thing', 'stuff')
+    test.addField('thing')
+    test.addResource('thing', 'thing', 'thing')
+    test.addFilter('thing', 'thing')
+    test.addCollection('thing3')
+    test.addLink('test')
+    test.addInclude('thing')
+    test.addResource('test')
+    test.resources[0].addResult('test')
+    test.resources[0].setMetadata('planned')
+    test.resources[0].metadata.addLog('read', 'planned', '10', '20', 'dude', 'test')
+    test.resources[0].addFragment('test')
+    test.resources[0].addText('some', 'some', 'some', 'preserve', 'some')
+    test.resources[0].addException('test')
+    test.resources[0].addParameter('test')
+    test.resources[0].addResult('test2')
+    test.resources[0].addFilter('test')
+    test.resources[0].filters[0].addAccess('grant', 'ssl', 'dude')
+    test.resources[0].filters[0].acl[0].addRight('read')
+    test.resources[0].addLink('something')
+    test.resources[0].addParameter('test2')
+    test.resources[0].addField('test')
+    test.resources[0].addFragment('test2')
+    test.resources[0].addField('something')
+    test.resources[0].addException('thing', 'thing', 'thing')
+    test.resources[0].addInclude('test')
+    test.resources[0].addResult('test3')
+    test.setMetadata()
+    test.addCollection('test3')
+    document = Root()
+    psi = Psi()
+    psi.appendChild(test)
+    document.appendChild(psi)
+    print document       
 
 if __name__ == '__main__': testSom()