def test_creation(self): fq = FractionQuestion() oper = Oper.objects.get(pk=1) fs = createFraction(0,oper) fq.f1 = fs[0] fq.f2 = fs[1] fq.oper = Oper.objects.get(pk=1) fq.answer = fs[2]
def test_equality(self): oper = Oper.objects.get(pk=1) fq1 = FractionQuestion() fs = createFraction(0,oper) fq1.f1 = fs[0] fq1.f2 = fs[1] fq1.oper = Oper.objects.get(pk=1) fq1.answer = fs[2] fq2 = FractionQuestion() fs = createFraction(1,oper) fq2.f1 = fs[0] fq2.f2 = fs[1] fq2.oper = Oper.objects.get(pk=1) fq2.answer = fs[2] eq = fq1 == fq2 self.assertEquals(eq, False)
def test_add_identical_items(self): fb = FractionBank() fb.name = "Bank 0 to 4" fb.date_created = datetime.date(2012,03,07) fb.save() st = 0 en = 4 i = fb.fill(st,en) fbfs = FractionBankFraction.objects.all() fqb = FractionQuestionBank() fqb.name = "Addition 2" fqb.fraction_bank = fb fqb.date_created = datetime.date(2012,03,07) fqb.save() fq = FractionQuestion() fq.f1 = fbfs[0].fraction fq.f2 = fbfs[1].fraction oper = Oper.objects.get(pk=1) ans = fq.f1.oper(fq.f2,oper) ans.save() oper = Oper.objects.get(pk=1) fq.oper = oper fq.answer = ans fq.save() #Add question once fqb.add_question(fq) #Try and add same again fqb.add_question(fq) #Should fail gracefully and only one question in bank fbq = FractionBankQuestion.objects.all() self.assertEquals(len(fbq),1)
def test_creation(self): fb = FractionBank() fb.name = "Bank 1" fb.date_created = datetime.date(2012,03,07) fb.save() st = 0 en = 10 i = fb.fill(st,en) fbfs = FractionBankFraction.objects.all() fqb = FractionQuestionBank() fqb.name = "Addition 100" fqb.fraction_bank = fb fqb.date_created = datetime.date(2012,03,07) fqb.save() fq = FractionQuestion() fq.f1 = fbfs[0].fraction fq.f2 = fbfs[1].fraction oper = Oper.objects.get(pk=1) ans = fq.f1.oper(fq.f2,oper) ans.save() oper = Oper.objects.get(pk=1) fq.oper = oper fq.answer = ans fq.save() fbq = FractionBankQuestion() fbq.fraction_question_bank = fqb fbq.question = fq fbq.save() fbq = FractionBankQuestion.objects.all()[0] self.assertEquals(fbq.question.answer,ans)