def testGetLoopCommandList(self): ''' Test the correct working of the LoopCommandManager for loop tags with and without time info. :return: ''' loopCommandMgr = LoopCommandManager() sourcePathFileName = parentdir + "\\testclasses\\classloopnestedinneronefortestloopidxdic.py" fromClassName = 'ClassLoopNestedInnerOneForTestLoopIdxDic' fromMethodName = 'doB' with open(sourcePathFileName, "r") as f: contentList = f.readlines() methodDefLineIndex = [ i for (i, entry) in enumerate(contentList) if fromMethodName in entry ][0] loopCommandMgr.storeLoopCommands( fromClassName, fromMethodName, methodDefLineIndex + 1, [contentList[methodDefLineIndex:]]) value_17 = loopCommandMgr.getLoopCommandList(fromClassName, fromMethodName, 'doCWithNote', 17) self.assertEqual(len(value_17), 2) self.assertEqual(value_17[0], [':seqdiag_loop_start', '3 times', False], [':seqdiag_loop_start_end', '5 times', False]) value_20 = loopCommandMgr.getLoopCommandList(fromClassName, fromMethodName, 'doC2', 20) self.assertEqual(value_20[0], [':seqdiag_loop_end', '', False])
def testGetOutOfRecordedFlowLoopCommandListTwoUnconsumedCommandsOnSameLines( self): loopCommandMgr = LoopCommandManager() sourcePathFileName = parentdir + "\\testclasses\\classloopnestedinneronefortestloopidxdic.py" fromClassName = 'ClassLoopNestedInnerOneForTestLoopIdxDic' fromMethodName = 'doB' with open(sourcePathFileName, "r") as f: contentList = f.readlines() methodDefLineIndex = [ i for (i, entry) in enumerate(contentList) if fromMethodName in entry ][0] loopCommandMgr.storeLoopCommands( fromClassName, fromMethodName, methodDefLineIndex + 1, [contentList[methodDefLineIndex:]]) loopCommandMgr.setLoopCommandIsOnFlow(0, fromClassName, fromMethodName, 'doC2', 20) outOfFlowLoopCommandList = loopCommandMgr.getOutOfRecordedFlowLoopCommandList( ) self.assertEqual(outOfFlowLoopCommandList, [ [ 'ClassLoopNestedInnerOneForTestLoopIdxDic.doB->doCWithNote: 17', [':seqdiag_loop_start', '3 times', False] ], [ 'ClassLoopNestedInnerOneForTestLoopIdxDic.doB->doCWithNote: 17', [':seqdiag_loop_start', '3 times', False] ] ])
def testSetLoopCommandIsOnFlow(self): loopCommandMgr = LoopCommandManager() sourcePathFileName = parentdir + "\\testclasses\\classloopnestedinneronefortestloopidxdic.py" fromClassName = 'ClassLoopNestedInnerOneForTestLoopIdxDic' fromMethodName = 'doB' with open(sourcePathFileName, "r") as f: contentList = f.readlines() methodDefLineIndex = [ i for (i, entry) in enumerate(contentList) if fromMethodName in entry ][0] loopCommandMgr.storeLoopCommands( fromClassName, fromMethodName, methodDefLineIndex + 1, [contentList[methodDefLineIndex:]]) value_17 = loopCommandMgr.getLoopCommandList(fromClassName, fromMethodName, 'doCWithNote', 17) loopCommandMgr.setLoopCommandIsOnFlow(0, fromClassName, fromMethodName, 'doCWithNote', 17) self.assertEqual(value_17[0], [':seqdiag_loop_start', '3 times', True], [':seqdiag_loop_start_end', '5 times', False]) loopCommandMgr.setLoopCommandIsOnFlow(1, fromClassName, fromMethodName, 'doCWithNote', 17) self.assertEqual(value_17[0], [':seqdiag_loop_start', '3 times', True], [':seqdiag_loop_start_end', '5 times', True]) value_20 = loopCommandMgr.getLoopCommandList(fromClassName, fromMethodName, 'doC2', 20) loopCommandMgr.setLoopCommandIsOnFlow(0, fromClassName, fromMethodName, 'doC2', 20) self.assertEqual(value_20[0], [':seqdiag_loop_end', '', True])
def testGetOutOfRecordedFlowLoopCommandListNoUnconsumedCommands(self): loopCommandMgr = LoopCommandManager() sourcePathFileName = parentdir + "\\testclasses\\classloopnestedinneronefortestloopidxdic.py" fromClassName = 'ClassLoopNestedInnerOneForTestLoopIdxDic' fromMethodName = 'doB' with open(sourcePathFileName, "r") as f: contentList = f.readlines() methodDefLineIndex = [ i for (i, entry) in enumerate(contentList) if fromMethodName in entry ][0] loopCommandMgr.storeLoopCommands( fromClassName, fromMethodName, methodDefLineIndex + 1, [contentList[methodDefLineIndex:]]) loopCommandMgr.setLoopCommandIsOnFlow(0, fromClassName, fromMethodName, 'doCWithNote', 17) loopCommandMgr.setLoopCommandIsOnFlow(1, fromClassName, fromMethodName, 'doCWithNote', 17) loopCommandMgr.setLoopCommandIsOnFlow(0, fromClassName, fromMethodName, 'doC2', 20) self.assertIsNone(loopCommandMgr.getOutOfRecordedFlowLoopCommandList())