def testGenerateFactsDefaultsThirtyFacts(self): high = 12 low = 0 results = facts.generatefacts(low, high) self.assertEquals(30,len(results))
def genfacts(self, low=0, high=12, amount=30, op=''): fs = facts.generatefacts(int(low),int(high),int(amount),op) latex.buildlatexfile(fs) filename = 'arithmetic.pdf' call('pdflatex arithmetic.tex', shell=True) returnfile = open(filename,'rb') return serve_fileobj(returnfile,disposition='attachment', content_type='application/pdf',name=filename)
def genfacts(self, low=0, high=12, amount=30, op=''): fs = facts.generatefacts(int(low), int(high), int(amount), op) latex.buildlatexfile(fs) filename = 'arithmetic.pdf' call('pdflatex arithmetic.tex', shell=True) returnfile = open(filename, 'rb') return serve_fileobj(returnfile, disposition='attachment', content_type='application/pdf', name=filename)
def testGenerateFactsDefaultsToZeroToTwelve(self): high = 12 low = 0 amount = 500 results = facts.generatefacts(low, high, amount) for fact in results: self.assertTrue(low <= fact.left <= high) self.assertTrue(low <= fact.right <= high)
def testGenerateFactsStaysWithinLimits(self): high = 15 low = 2 amount = 500 results = facts.generatefacts(low, high, amount) for fact in results: self.assertTrue(low <= fact.left <= high) self.assertTrue(low <= fact.right <= high)
def testGenerateFactsCanGiveMixOfPlusMinus(self): results = facts.generatefacts(amount=500) pluscount = 0 minuscount = 0 for fact in results: if fact.sign == '+': pluscount += 1 elif fact.sign == '-': minuscount += 1 else: self.assertFalse(True) self.assertEquals(500,pluscount+minuscount) self.assertTrue(200 < pluscount < 300)
def testGenerateFactsCanGivePlus(self): results = facts.generatefacts(op='+') for fact in results: self.assertEquals('+',fact.sign)
def testGenerateFactsYieldsNoNegatives(self): results = facts.generatefacts(amount=500, op='-') for fact in results: self.assertTrue(fact.result >= 0)