-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_survey.py
More file actions
29 lines (21 loc) · 1000 Bytes
/
test_survey.py
File metadata and controls
29 lines (21 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from survey import AnonymousSurvey
class TestAnonymousSurvey(unittest.TestCase):
"""Tests for the class AnonymousSurvey"""
def setUp(self):
"""Create a survey and a set of responses to use in all test methods"""
question = "What language did you first learn?"
self.my_survey = AnonymousSurvey(question)
self.responses = ["English", "Spanish", "Mandarin"]
def test_store_single_response(self):
"""Test that a single response is stored properly"""
self.my_survey.store_response(self.responses[0])
self.assertIn(self.responses[0], self.my_survey.responses)
def test_store_three_responses(self):
"""Test that three individual responses are stored properly"""
for response in self.responses:
self.my_survey.store_response(response)
for response in self.responses:
self.assertIn(response, self.my_survey.responses)
if __name__ == "__main__":
unittest.main()