Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 2 Deliverable E #23

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/test_data_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{,,,,}
32 changes: 27 additions & 5 deletions test/quizzes_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from datetime import datetime
import unittest
import json

from app.controllers.quizzes_controller import QuizzesController

Expand All @@ -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()
unittest.main()