<s> """<STR_LIT>""" <EOL> import unittest <EOL> import os <EOL> import time <EOL> import sys <EOL> import random <EOL> from sonLib . bioio import parseSuiteTestOptions <EOL> from sonLib . bioio import logger , system <EOL> from jobTree . src . job import Job <EOL> class TestCase ( unittest . TestCase ) : <EOL> def testJobReadWriteAndDelete ( self ) : <EOL> jobDir = os . path . join ( os . getcwd ( ) , "<STR_LIT>" ) <EOL> os . mkdir ( jobDir ) <EOL> command = "<STR_LIT>" <EOL> memory = <NUM_LIT:2> ^ <NUM_LIT:32> <EOL> cpu = <NUM_LIT:1> <EOL> tryCount = <NUM_LIT:100> <EOL> for i in xrange ( <NUM_LIT:10> ) : <EOL> startTime = time . time ( ) <EOL> for j in xrange ( <NUM_LIT:100> ) : <EOL> j = Job ( command , memory , cpu , tryCount , jobDir ) <EOL> self . assertEquals ( j . remainingRetryCount , tryCount ) <EOL> self . assertEquals ( j . jobDir , jobDir ) <EOL> self . assertEquals ( j . children , [ ] ) <EOL> self . assertEquals ( j . followOnCommands , [ ( command , memory , cpu , <NUM_LIT:0> ) ] ) <EOL> self . assertEquals ( j . messages , [ ] ) <EOL> j . write ( ) <EOL> j = Job . read ( j . getJobFileName ( ) ) <EOL> self . assertEquals ( j . remainingRetryCount , tryCount ) <EOL> self . assertEquals ( j . jobDir , jobDir ) <EOL> self . assertEquals ( j . children , [ ] ) <EOL> self . assertEquals ( j . followOnCommands , [ ( command , memory , cpu , <NUM_LIT:0> ) ] ) <EOL> self . assertEquals ( j . messages , [ ] ) <EOL> self . assertTrue ( os . path . exists ( j . getJobFileName ( ) ) ) <EOL> j . delete ( ) <EOL> self . assertTrue ( not os . path . exists ( j . getJobFileName ( ) ) ) <EOL> print "<STR_LIT>" % ( time . time ( ) - startTime ) <EOL> system ( "<STR_LIT>" % jobDir ) <EOL> def testJobUpdate ( self ) : <EOL> jobDir = os . path . join ( os . getcwd ( ) , "<STR_LIT>" ) <EOL> os . mkdir ( jobDir ) <EOL> command = "<STR_LIT>" <EOL> memory = <NUM_LIT:2> ^ <NUM_LIT:32> <EOL> cpu = <NUM_LIT:1> <EOL> tryCount = <NUM_LIT:100> <EOL> for i in xrange ( <NUM_LIT> ) : <EOL> startTime = time . time ( ) <EOL> j = Job ( command , memory , cpu , tryCount , jobDir ) <EOL> childNumber = random . choice ( range ( <NUM_LIT:20> ) ) <EOL> for k in xrange ( childNumber ) : <EOL> j . children . append ( ( command , memory , cpu ) ) <EOL> self . assertEquals ( len ( j . children ) , childNumber ) <EOL> j . update ( tryCount = tryCount , depth = <NUM_LIT:0> ) <EOL> j = Job . read ( j . getJobFileName ( ) ) <EOL> self . assertEquals ( len ( j . children ) + len ( j . followOnCommands ) , childNumber + <NUM_LIT:1> ) <EOL> for childJobFile , memory , cpu in j . children : <EOL> cJ = Job . read ( childJobFile ) <EOL> self . assertEquals ( cJ . remainingRetryCount , tryCount ) <EOL> self . assertEquals ( cJ . children , [ ] ) <EOL> self . assertEquals ( cJ . followOnCommands , [ ( command , memory , cpu , <NUM_LIT:0> ) ] ) <EOL> self . assertEquals ( cJ . messages , [ ] ) <EOL> self . assertTrue ( os . path . exists ( cJ . getJobFileName ( ) ) ) <EOL> cJ . delete ( ) <EOL> self . assertTrue ( not os . path . exists ( cJ . getJobFileName ( ) ) ) <EOL> self . assertEquals ( os . listdir ( jobDir ) , [ "<STR_LIT>" ] ) <EOL> j . delete ( ) <EOL> print "<STR_LIT>" % ( time . time ( ) - startTime ) <EOL> system ( "<STR_LIT>" % jobDir ) <EOL> def main ( ) : <EOL> parseSuiteTestOptions ( ) <EOL> sys . argv = sys . argv [ : <NUM_LIT:1> ] <EOL> unittest . main ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
