def test_exports_specific_version(self):
        primary_question_answer2 = MultiChoiceAnswer.objects.create(question=self.primary_question,
                                                                    country=self.country,
                                                                    status=Answer.SUBMITTED_STATUS,
                                                                    response=self.option2, version=2, questionnaire=self.questionnaire)
        question1_answer2 = NumericalAnswer.objects.create(question=self.question1, country=self.country,
                                                           status=Answer.SUBMITTED_STATUS, response=4, version=2, questionnaire=self.questionnaire)
        question2_answer2 = NumericalAnswer.objects.create(question=self.question2, country=self.country,
                                                           status=Answer.SUBMITTED_STATUS, response=55, version=2, questionnaire=self.questionnaire)
        answer_group2 = primary_question_answer2.answergroup.create(grouped_question=self.parent, row=2)
        answer_group2_1 = question1_answer2.answergroup.create(grouped_question=self.parent, row=2)
        answer_group2_2 = question2_answer2.answergroup.create(grouped_question=self.parent, row=2)

        question_text = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.primary_question.text)
        question_text1 = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.question1.text)
        question_text_2 = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.question2.text)
        answer_id = "C_%s_%s_%s" % (self.primary_question.UID, self.primary_question.UID, self.option2.UID)
        answer_id_1 = "C_%s_%s_2" % (self.primary_question.UID, self.question1.UID)
        answer_id_2 = "C_%s_%s_2" % (self.primary_question.UID, self.question2.UID)

        expected_data = [self.headings,
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id.encode('base64').strip(), question_text, self.option2.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_1.encode('base64').strip(), question_text1, '4.00'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_2.encode('base64').strip(), question_text_2, '55.00')]

        export_to_text_service = ExportToTextService([self.questionnaire], version=2)
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
        self.assertIn(expected_data[1], actual_data)
    def test_draft_answers_does_not_show_on_extract_questionnaire_answers(
            self):
        Question.objects.all().delete()
        question = Question.objects.create(text='what do you drink?',
                                           UID='abc123',
                                           answer_type='Text')
        parent = QuestionGroup.objects.create(subsection=self.sub_section,
                                              order=2)
        parent.question.add(question)

        QuestionGroupOrder.objects.create(question=question,
                                          question_group=parent,
                                          order=1)

        country = Country.objects.create(name="Uganda", code="UGX")
        answer1 = TextAnswer.objects.create(question=question,
                                            country=country,
                                            response="tusker lager",
                                            status=Answer.DRAFT_STATUS)

        answer_group1 = AnswerGroup.objects.create(grouped_question=parent,
                                                   row=1)
        answer_group1.answer.add(answer1)

        expected_data = [
            self.headings,
        ]

        export_to_text_service = ExportToTextService(self.questionnaire)
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
    def test_exports_single_question_in_a_group_questionnaire(self):
        Question.objects.all().delete()
        question = Question.objects.create(text='what do you drink?', UID='abc123', answer_type='Text')
        parent = QuestionGroup.objects.create(subsection=self.sub_section, order=2)
        parent.question.add(question)

        QuestionGroupOrder.objects.create(question=question, question_group=parent, order=1)

        country = Country.objects.create(name="Uganda", code="UGX")
        answer1 = TextAnswer.objects.create(question=question, country=country, response="tusker lager",
                                            status=Answer.SUBMITTED_STATUS,
                                            questionnaire=self.questionnaire)

        answer_group1 = AnswerGroup.objects.create(grouped_question=parent, row=1)
        answer_group1.answer.add(answer1)

        question_text = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, question.text)
        answer_id = "C_%s_%s_1" % (question.UID, question.UID)

        expected_data = [self.headings,
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id.encode('base64').strip(), question_text, 'tusker lager')]

        export_to_text_service = ExportToTextService([self.questionnaire])
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
    def test_exports_questions_with_normal_group(self):
        question_text = "%s | %s" % (self.section_1.name, self.question.text)
        question_text1 = "%s | %s" % (self.section_1.name, self.question1.text)
        question_text_2 = "%s | %s" % (self.section_1.name, self.question2.text)
        question_text_3 = "%s | %s" % (self.section_1.name, self.question3.text)

        answer_id = "C_%s_%s_%s" % (self.question.UID, self.question.UID, self.option.UID)
        answer_id_1 = "C_%s_%s" % (self.question.UID, self.question1.UID)
        answer_id_2 = "C_%s_%s" % (self.question.UID, self.question2.UID)
        answer_id_3 = "C_%s_%s" % (self.question.UID, self.question3.UID)
        options_as_comma_separated_text = (self.male_option.text, self.female_option.text)
        expected_data = [self.headings,
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id.encode('base64').strip(), question_text, self.option.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_1.encode('base64').strip(), question_text1, '23'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_2.encode('base64').strip(), question_text_2, '1'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_3.encode('base64').strip(), question_text_3,
                             '%s, %s' % options_as_comma_separated_text)]

        export_to_text_service = ExportToTextService([self.questionnaire])
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)

        self.assertIn(expected_data[1], actual_data)
        self.assertIn(expected_data[2], actual_data)
        self.assertIn(expected_data[3], actual_data)
        self.assertIn(expected_data[4], actual_data)
    def test_grid_display_all_answers(self):
        question_text = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.primary_question.text)
        question_text1 = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.question1.text)
        question_text_2 = "%s | %s | %s" % (self.section_1.title, self.sub_section.title, self.question2.text)
        answer_id = "C_%s_%s_%s" % (self.primary_question.UID, self.primary_question.UID, self.option.UID)
        answer_id_1 = "C_%s_%s_1" % (self.primary_question.UID, self.question1.UID)
        answer_id_2 = "C_%s_%s_1" % (self.primary_question.UID, self.question2.UID)
        answer_id_10 = "C_%s_%s_%s" % (self.primary_question.UID, self.primary_question.UID, self.option2.UID)
        answer_id_11 = "C_%s_%s_2" % (self.primary_question.UID, self.question1.UID)
        answer_id_21 = "C_%s_%s_2" % (self.primary_question.UID, self.question2.UID)
        expected_data = [self.headings,
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id.encode('base64').strip(), question_text, self.option.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_1.encode('base64').strip(), question_text1, '23.00'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_2.encode('base64').strip(), question_text_2, '1.00'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_10.encode('base64').strip(), question_text, self.option2.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_11.encode('base64').strip(), question_text1, '3.00'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                         self.country.name, answer_id_21.encode('base64').strip(), question_text_2, '12.00')]

        export_to_text_service = ExportToTextService([self.questionnaire])
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
        self.assertIn(expected_data[1], actual_data)
        self.assertIn(expected_data[2], actual_data)
        self.assertIn(expected_data[3], actual_data)
        self.assertIn(expected_data[4], actual_data)
        self.assertIn(expected_data[5], actual_data)
    def test_exports_questions_with_numeric_answers(self):
        question_text = "%s | %s | %s" % (self.section_1.title,
                                          self.sub_section.title,
                                          self.primary_question.text)
        question_text1 = "%s | %s | %s" % (
            self.section_1.title, self.sub_section.title, self.question1.text)
        question_text_2 = "%s | %s | %s" % (
            self.section_1.title, self.sub_section.title, self.question2.text)
        answer_id = "R_%s_%s_%s" % (self.primary_question.UID,
                                    self.primary_question.UID, self.option.UID)
        answer_id_1 = "R_%s_%s_1" % (self.primary_question.UID,
                                     self.question1.UID)
        answer_id_2 = "R_%s_%s_%d_1" % (self.primary_question.UID,
                                        self.question1.UID, 1)
        expected_data = [
            self.headings,
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id.encode('base64').strip(),
             question_text, self.option.text),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_1.encode('base64').strip(),
             question_text1, '23.00'),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_2.encode('base64').strip(),
             question_text_2, '1.00')
        ]

        export_to_text_service = ExportToTextService(self.questionnaire)
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
        self.assertIn(expected_data[1], actual_data)
    def test_exports_questions_with_two_versions(self):
        primary_question_answer2 = MultiChoiceAnswer.objects.create(question=self.question,
                                                                    country=self.country,
                                                                    status=Answer.SUBMITTED_STATUS,
                                                                    response=self.option2,
                                                                    questionnaire=self.questionnaire)
        question1_answer2 = NumericalAnswer.objects.create(question=self.question1, country=self.country,
                                                           status=Answer.SUBMITTED_STATUS, response=4,
                                                           questionnaire=self.questionnaire)
        question2_answer2 = NumericalAnswer.objects.create(question=self.question2, country=self.country,
                                                           status=Answer.SUBMITTED_STATUS, response=55,
                                                           questionnaire=self.questionnaire)
        answer_group2 = primary_question_answer2.answergroup.create(grouped_question=self.parent, row=2)
        answer_group2_1 = question1_answer2.answergroup.create(grouped_question=self.parent, row=2)
        answer_group2_2 = question2_answer2.answergroup.create(grouped_question=self.parent, row=2)

        question_text = "%s | %s" % (self.section_1.name, self.question.text)
        question_text1 = "%s | %s" % (self.section_1.name, self.question1.text)
        question_text_2 = "%s | %s" % (self.section_1.name, self.question2.text)
        question_text_3 = "%s | %s" % (self.section_1.name, self.question3.text)

        answer_id = "C_%s_%s_%s" % (self.question.UID, self.question.UID, self.option.UID)
        answer_id_1 = "C_%s_%s" % (self.question.UID, self.question1.UID)
        answer_id_2 = "C_%s_%s" % (self.question.UID, self.question2.UID)
        answer_id_10 = "C_%s_%s_%s" % (self.question.UID, self.question.UID, self.option2.UID)
        answer_id_11 = "C_%s_%s" % (self.question.UID, self.question1.UID)
        answer_id_21 = "C_%s_%s" % (self.question.UID, self.question2.UID)
        answer_id_3 = "C_%s_%s" % (self.question.UID, self.question3.UID)
        options_as_comma_separated_text = (self.male_option.text, self.female_option.text)

        expected_data = [self.headings,
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id.encode('base64').strip(), question_text, self.option.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_1.encode('base64').strip(), question_text1, '23'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_2.encode('base64').strip(), question_text_2, '1'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (self.country.name, answer_id_3.encode('base64').strip(),
                                                        question_text_3, '%s, %s' % options_as_comma_separated_text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_10.encode('base64').strip(), question_text,
                             self.option2.text),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_11.encode('base64').strip(), question_text1, '4'),
                         "UGX\t%s\t2013\t%s\t%s\t%s" % (
                             self.country.name, answer_id_21.encode('base64').strip(), question_text_2, '55')
        ]

        export_to_text_service = ExportToTextService([self.questionnaire])
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
        self.assertIn(expected_data[1], actual_data)
        self.assertIn(expected_data[2], actual_data)
        self.assertIn(expected_data[3], actual_data)
        self.assertIn(expected_data[4], actual_data)
        self.assertIn(expected_data[5], actual_data)
        self.assertIn(expected_data[6], actual_data)
    def test_export_of_question_and_answers_when_no_questionnaires_available(self):
        expected_data = [self.headings]
        line_format = "UGX\t%s\t2013\t%s\t%s\t%s"

        export_to_text_service = ExportToTextService(questionnaires=[])
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
    def test_export_of_question_and_answers_for_theme_and_invalid_country(self):
        expected_data = [self.headings]
        line_format = "UGX\t%s\t2013\t%s\t%s\t%s"

        export_to_text_service = ExportToTextService(questionnaires=[self.questionnaire], countries=[self.country_2], themes=[self.theme])
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
Beispiel #10
0
 def post(self, *args, **kwargs):
     country = Country.objects.get(id=kwargs['country_id'])
     questionnaire = Questionnaire.objects.filter(region__countries=country, status=Questionnaire.PUBLISHED).latest('modified')
     version = kwargs.get('version_number', None)
     export_service = ExportToTextService([questionnaire], countries=[country], version=version)
     formatted_responses = export_service.get_formatted_responses()
     response = HttpResponse(content_type='text/csv')
     filename_parts = (questionnaire.name, questionnaire.year, country.name, version)
     response['Content-Disposition'] = 'attachment; filename="%s-%s-%s-%s.txt"' % filename_parts
     response.write("\r\n".join(formatted_responses))
     return response
    def test_export_of_question_and_answers_for_theme_and_invalid_country(self):
        expected_data = [self.headings]

        questionnaires = [self.questionnaire1_data['questionnaire']]
        export_to_text_service = ExportToTextService(questionnaires=questionnaires, countries=[self.country_2],
                                                     themes=[self.theme])
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        for expected_row in expected_data:
            self.assertIn(expected_row, actual_data)
    def test_export_questions_and_answers_for_particular_country(self):
        expected_data = [self.headings]

        questionnaire1_questions = self.questionnaire1_data['questions']
        for question in questionnaire1_questions:
            self.create_export_data_rows(question, expected_data=expected_data, **self.questionnaire1_data)

        questionnaires = [self.questionnaire1_data['questionnaire'], self.questionnaire2_data['questionnaire']]
        export_to_text_service = ExportToTextService(questionnaires=questionnaires, countries=[self.country])
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        for expected_row in expected_data:
            self.assertIn(expected_row, actual_data)
    def test_export_of_question_and_answers_for_theme_and_country(self):
        expected_data = [self.headings]
        line_format = "UGX\t%s\t2013\t%s\t%s\t%s"

        #questionnaire 1
        for number in range(0, 3, 1):
            question = self.subsection.all_questions()[number]
            question_text = "%s | %s | %s" % (self.section.title, self.subsection.title, question.text)
            answer_id = "C_%s_%s_1" % (question.UID, question.UID)
            expected_data.append(line_format % (self.country.name, answer_id.encode('base64').strip(), question_text, '23'))

        export_to_text_service = ExportToTextService(questionnaires=[self.questionnaire,self.questionnaire2], countries=[self.country], themes=[self.theme])
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
Beispiel #14
0
    def post(self, *args, **kwargs):
        years = None
        filter_form = ExportFilterForm(self.request.POST)
        all_questionnaires = Questionnaire.objects.all()
        export_service = ExportToTextService(questionnaires=all_questionnaires)
        if filter_form.is_valid():
            years = filter_form.cleaned_data['year']
            countries = filter_form.cleaned_data['countries']
            themes = filter_form.cleaned_data['themes']
            export_filter_params = {'year__in': years, 'region__in': filter_form.cleaned_data['regions']}

            questionnaires = all_questionnaires.filter(**export_filter_params)
            export_service = ExportToTextService(questionnaires=questionnaires, countries=countries, themes=themes)

        formatted_responses = export_service.get_formatted_responses()
        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'] = 'attachment; filename="%s-%s.txt"' % ('data', '_'.join(years) or self.ALL_QUESTIONNAIRES)
        response.write("\r\n".join(formatted_responses))
        return response
Beispiel #15
0
 def post(self, request, *args, **kwargs):
     questionnaire = Questionnaire.objects.get(
         id=request.POST['questionnaire'])
     formatted_responses = ExportToTextService(
         questionnaire).get_formatted_responses()
     response = HttpResponse(content_type='text/csv')
     response[
         'Content-Disposition'] = 'attachment; filename="%s-%s.txt"' % (
             questionnaire.name, questionnaire.year)
     response.write("\r\n".join(formatted_responses))
     return response
    def test_draft_answers_does_not_show_on_extract_questionnaire_answers(self):
        Question.objects.all().delete()
        question = Question.objects.create(text='what do you drink?', UID='abc123', answer_type='Text')
        parent = QuestionGroup.objects.create(subsection=self.sub_section, order=2)
        parent.question.add(question)

        QuestionGroupOrder.objects.create(question=question, question_group=parent, order=1)

        country = Country.objects.create(name="Uganda", code="UGX")
        answer1 = TextAnswer.objects.create(question=question, country=country, response="tusker lager",
                                            status=Answer.DRAFT_STATUS,
                                            questionnaire=self.questionnaire)

        answer_group1 = AnswerGroup.objects.create(grouped_question=parent, row=1)
        answer_group1.answer.add(answer1)

        expected_data = [self.headings, ]

        export_to_text_service = ExportToTextService([self.questionnaire])
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
    def test_exports_single_question_in_a_group_questionnaire(self):
        Question.objects.all().delete()
        question = Question.objects.create(text='what do you drink?',
                                           UID='abc123',
                                           answer_type='Text')
        parent = QuestionGroup.objects.create(subsection=self.sub_section,
                                              order=2)
        parent.question.add(question)

        QuestionGroupOrder.objects.create(question=question,
                                          question_group=parent,
                                          order=1)

        country = Country.objects.create(name="Uganda", code="UGX")
        answer1 = TextAnswer.objects.create(question=question,
                                            country=country,
                                            response="tusker lager",
                                            status=Answer.SUBMITTED_STATUS)

        answer_group1 = AnswerGroup.objects.create(grouped_question=parent,
                                                   row=1)
        answer_group1.answer.add(answer1)

        question_text = "%s | %s | %s" % (
            self.section_1.title, self.sub_section.title, question.text)
        answer_id = "R_%s_%s_1" % (question.UID, question.UID)

        expected_data = [
            self.headings,
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id.encode('base64').strip(),
             question_text, 'tusker lager')
        ]

        export_to_text_service = ExportToTextService(self.questionnaire)
        actual_data = export_to_text_service.get_formatted_responses()
        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
    def test_exports_questions_with_two_rows_answer_grid(self):
        primary_question_answer2 = MultiChoiceAnswer.objects.create(
            question=self.primary_question,
            country=self.country,
            status=Answer.SUBMITTED_STATUS,
            response=self.option2)
        question1_answer2 = NumericalAnswer.objects.create(
            question=self.question1,
            country=self.country,
            status=Answer.SUBMITTED_STATUS,
            response=4)
        question2_answer2 = NumericalAnswer.objects.create(
            question=self.question2,
            country=self.country,
            status=Answer.SUBMITTED_STATUS,
            response=55)
        answer_group2 = AnswerGroup.objects.create(
            grouped_question=self.parent, row=2)
        answer_group2.answer.add(primary_question_answer2, question1_answer2,
                                 question2_answer2)
        question_text = "%s | %s | %s" % (self.section_1.title,
                                          self.sub_section.title,
                                          self.primary_question.text)
        question_text1 = "%s | %s | %s" % (
            self.section_1.title, self.sub_section.title, self.question1.text)
        question_text_2 = "%s | %s | %s" % (
            self.section_1.title, self.sub_section.title, self.question2.text)
        answer_id = "R_%s_%s_%s" % (self.primary_question.UID,
                                    self.primary_question.UID, self.option.UID)
        answer_id_1 = "R_%s_%s_1" % (self.primary_question.UID,
                                     self.question1.UID)
        answer_id_2 = "R_%s_%s_1" % (self.primary_question.UID,
                                     self.question2.UID)
        answer_id_10 = "R_%s_%s_%s" % (self.primary_question.UID,
                                       self.primary_question.UID,
                                       self.option2.UID)
        answer_id_11 = "R_%s_%s_2" % (self.primary_question.UID,
                                      self.question1.UID)
        answer_id_21 = "R_%s_%s_2" % (self.primary_question.UID,
                                      self.question2.UID)
        expected_data = [
            self.headings,
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id.encode('base64').strip(),
             question_text, self.option.text),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_1.encode('base64').strip(),
             question_text1, '23.00'),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_2.encode('base64').strip(),
             question_text_2, '1.00'),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_10.encode('base64').strip(),
             question_text, self.option2.text),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_11.encode('base64').strip(),
             question_text1, '4.00'),
            "UGX\t%s\t2013\t%s\t%s\t%s" %
            (self.country.name, answer_id_21.encode('base64').strip(),
             question_text_2, '55.00')
        ]

        export_to_text_service = ExportToTextService(self.questionnaire)
        actual_data = export_to_text_service.get_formatted_responses()

        self.assertEqual(len(expected_data), len(actual_data))
        self.assertIn(expected_data[0], actual_data)
        self.assertIn(expected_data[1], actual_data)
        self.assertIn(expected_data[2], actual_data)
        self.assertIn(expected_data[3], actual_data)
        self.assertIn(expected_data[4], actual_data)
        self.assertIn(expected_data[5], actual_data)