diff --git a/data/test_data_1 b/data/test_data_1 new file mode 100644 index 0000000..b4b5db8 --- /dev/null +++ b/data/test_data_1 @@ -0,0 +1 @@ +{,,,,} diff --git a/test/quizzes_test.py b/test/quizzes_test.py index c4c1214..d791026 100644 --- a/test/quizzes_test.py +++ b/test/quizzes_test.py @@ -1,4 +1,6 @@ +from datetime import datetime import unittest +import json from app.controllers.quizzes_controller import QuizzesController @@ -10,11 +12,31 @@ def setUp(self): def test_expose_failure_01(self): """ - Implement this function and two more that - execute the code and make it fail. + We load a JSON file that is empty + + json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes + File: quizzes_controller.py, Line: 63 """ - self.assertTrue(True, 'Example assertion.') - + with self.assertRaises(json.decoder.JSONDecodeError): + QuizzesController("bad_data.json") + + def test_expose_failure_02(self): + ''' + Crash in QuizzesController.add_answer() when adding an answer to a non-existent question + File: quizzes_controller.py, Line: 88 + ''' + self.ctrl.clear_data() + with self.assertRaises(AttributeError): + self.ctrl.add_answer('non-existent-question-id', 'text', True) + + def test_expose_failure_03(self): + """ + Testing the ability to add question to a non-existent-quiz-id + Failed at line 39, initiating from quizzes_controller.py at line 75, quiz with id 'non-existent-quiz-id' does not exist. + """ + controller = QuizzesController() + with self.assertRaises(AttributeError): + controller.add_question('non-existent-quiz-id', 'title', 'text') if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()