Skip to content

Commit

Permalink
Add missing tests for result page
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Pablo Santos committed Aug 25, 2015
1 parent 2a93a03 commit 82a9057
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[run]
omit=automated_survey/settings/*
omit=
automated_survey/settings/*
automated_survey/tests/*
automated_survey/wsgi.py
35 changes: 34 additions & 1 deletion automated_survey/tests/surveys_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.test import TestCase
from automated_survey.models import Survey, Question
from automated_survey.models import Survey, Question, QuestionResponse
from django.core.urlresolvers import reverse


Expand Down Expand Up @@ -36,3 +36,36 @@ def test_redirect_to_first_question(self):
response = self.client.get(reverse('survey', kwargs={'survey_id': survey.id}))

assert question_url in response.content.decode('utf8')


class SurveyResultsTest(TestCase):

def test_render_context(self):
survey = Survey(title='A testing survey')
survey.save()

question_one = Question(body='Question one', kind='voice', survey=survey)
question_one.save()

question_response = QuestionResponse(response='gopher://someaudio.mp3',
call_sid='sup3runiq3',
phone_number='+14155552671',
question=question_one)

question_response.save()

redirect = self.client.get('/')
survey_results_url = reverse('survey-results', kwargs={'survey_id': survey.id})

assert survey_results_url in redirect.url

response = self.client.get(survey_results_url)

expected_responses = [{'body': 'Question one',
'phone_number': '+14155552671',
'kind': 'voice',
'response': 'gopher://someaudio.mp3',
'call_sid': 'sup3runiq3'}]

assert expected_responses == response.context['responses']
assert survey.title == response.context['survey_title']

0 comments on commit 82a9057

Please sign in to comment.