def test_has_unanswered_questions(self): tender = Tender(self.tender_data) tender.lots = self.lots tender.items = self.items tender.questions = [Question({ 'questionOf': 'lot', 'relatedItem': '11111111111111111111111111111111', 'title': 'Do you have some Earth?' })] self.assertEqual(True, has_unanswered_questions(tender)) self.assertEqual(True, has_unanswered_questions(tender, False)) tender.questions[0].answer = 'No' self.assertEqual(False, has_unanswered_questions(tender)) self.assertEqual(False, has_unanswered_questions(tender, False))
def test_has_unanswered_questions(self): tender = Tender(self.tender_data) tender.lots = self.lots tender.items = self.items tender.questions = [ Question({ "questionOf": "lot", "relatedItem": "11111111111111111111111111111111", "title": "Do you have some Earth?", }) ] self.assertEqual(True, has_unanswered_questions(tender)) self.assertEqual(True, has_unanswered_questions(tender, False)) tender.questions[0].answer = "No" self.assertEqual(False, has_unanswered_questions(tender)) self.assertEqual(False, has_unanswered_questions(tender, False))
def test_serialize_pre_qualification(self): question = Question() with self.assertRaises(ValueError) as e: question.serialize("invalid_role") self.assertIsInstance(e.exception, ValueError) self.assertEqual(str(e.exception), 'Question Model has no role "invalid_role"') serialized_question = question.serialize("active.pre-qualification") self.assertEqual(serialized_question["questionOf"], "tender") self.assertEqual(len(serialized_question["id"]), 32) serialized_question = question.serialize("active.pre-qualification.stand-still") self.assertEqual(serialized_question["questionOf"], "tender") self.assertEqual(len(serialized_question["id"]), 32)
def test_serialize_pre_qualification(self): question = Question() with self.assertRaises(ValueError) as e: question.serialize("invalid_role") self.assertIsInstance(e.exception, ValueError) self.assertEqual(e.exception.message, "Question Model has no role \"invalid_role\"") serialized_question = question.serialize("active.pre-qualification") self.assertEqual(serialized_question['questionOf'], 'tender') self.assertEqual(len(serialized_question['id']), 32) serialized_question = question.serialize( "active.pre-qualification.stand-still") self.assertEqual(serialized_question['questionOf'], 'tender') self.assertEqual(len(serialized_question['id']), 32)