예제 #1
0
 def test_appendInBlock(self):
     cbl=InPythonBlockLocator()
     m = Block.loadFromFile(pjoin(resDir, 'testBlockTree.html'))
     pybl = Block.loadFromFile(pjoin(resDir, 'testControllerBlocks.txt'),
                               cbl)
     pybl['ApplicationControllers'].append(Block.createEmptyBlock('TestControllers',cbl))
     pybl['ApplicationControllers.TestControllers'].append(Block.createLineBlock('bla bla bla'))
     f = open(pjoin(resDir, 'testControllerBlocks_rez.txt'), 'w')
     f.write(str(pybl))
     f.close()
예제 #2
0
 def test_loadFromFile(self):
     m = Block.loadFromFile(pjoin(resDir, 'testBlockTree.html'))
     pybl = Block.loadFromFile(pjoin(resDir, 'testControllerBlocks.txt'),
                               cbl=InPythonBlockLocator())
     self.assertEquals(m['root'].Name, 'root')
     self.assertEquals(m['root.child'].Name, 'child')
     #InPythonCodeBlocks
     self.assertEquals(pybl['ApplicationControllers'].Name,'ApplicationControllers')
     #Generic Code Blocks
     locator = GenericCbl(lambda x:x.replace(' ','').find('{%block')>-1 and 
                             strBetween(x.replace(' ',''), '{%block', '%}') or None , 
                          lambda x:x.replace(' ','').find('{%endblock%}')>-1)
     m = Block.loadFromFile(pjoin(resDir, 'testBlockTree.html'), locator)
     self.assertEquals(m['root'].Name, 'root')
     self.assertEquals(m['root.child'].Name, 'child')
예제 #3
0
 def test_LinesNumber(self):
     root = Block(None, 'root', blType=BlockTypes.BLOCK)
     for t in range(1, 51):
         root.append(Block.createLineBlock('Line '+str(t)))
     self.assertEqual(root.LineCount, 50)
     
     root = Block.loadFromFile(pjoin(resDir, 'testControllerBlocks.txt'))
     self.assertEquals(root.LineCount, 30)