-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
+from django.test import TestCase
-Replace this with more appropriate tests for your application.
-"""
+from multichoice.models import MCQuestion, Answer
-from django.test import TestCase
+
+class TestMCQuestionModel(TestCase):
+ def setUp(self):
+ q = MCQuestion.objects.create(id = 1,
+ content = ("WHAT is the airspeed" +
+ "velocity of an unladen" +
+ "swallow?"),
+ explanation = "I, I don't know that!",)
+
+ Answer.objects.create(question = q,
+ content = "African",
+ correct = False,)
+
+ Answer.objects.create(question = q,
+ content = "European",
+ correct = True)
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.assertEqual(1 + 1, 2)
+ def test_correct_answer(self):
+ china = Country.objects.get(name="China")
+ self.assertEqual(china.population, 1400000000)
+ self.assertEqual(china.climate, 'TEMPERATE')
+ self.assertEqual(china.healthcare, 4)
unique = True,
null = True,)
+ objects = CategoryManager()
class Meta:
verbose_name = "Category"
if first_comma == -1 or first_comma == 0:
return False
- return self.question_list[:first_comma]
+ return int(self.question_list[:first_comma])
def remove_first_question(self):
-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
-
-Replace this with more appropriate tests for your application.
-"""
-
from django.test import TestCase
+from quiz.models import Category, Quiz, Progress, Sitting, Question
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.assertEqual(1 + 1, 2)
+class TestCategory(TestCase):
+ def setUp(self):
+ Category.objects.new_category(category = "elderberries")
def check_if_correct(self, guess):
if guess == "T":
guess_bool = True
- else:
+ elif guess == "F":
guess_bool = False
+ else:
+ return False
if guess_bool == self.correct:
return True
from django.test import TestCase
-from django_quiz.true_false.models import TF_Question
+from true_false.models import TF_Question
class TestTrueFalseQuestionModel(TestCase):
def test_true_q(self):
red = TF_Question.objects.get(explanation = "it is")
self.assertEqual(red.correct, True)
+ self.assertEqual(red.check_if_correct("T"), True)
+ self.assertEqual(red.check_if_correct("F"), False)
+ self.assertEqual(red.check_if_correct("4"), False)
def test_false_q(self):
- red = TF_Question.objects.get(explanation = "it is not")
- self.assertEqual(red.correct, False)
+ blue = TF_Question.objects.get(explanation = "it is not")
+ self.assertEqual(blue.correct, False)
+ self.assertEqual(blue.check_if_correct("T"), False)
+ self.assertEqual(blue.check_if_correct("F"), True)