forked from ijasperyang/django-survey
-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permit to export survey with None value to CSV
Closes #70, this would be prevented by resolving #73 and #41 but we probably need to be able to handle None value anyway. Thanks to @ebdavison for its test data.
- Loading branch information
1 parent
fa61592
commit edf4e2c
Showing
9 changed files
with
59 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-01-26 18:37+0000\n" | ||
"POT-Creation-Date: 2020-02-05 22:05+0000\n" | ||
"PO-Revision-Date: 2020-01-24 17:05+0000\n" | ||
"Last-Translator: b' <>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -38,7 +38,7 @@ msgstr[1] "%(count)d Umfragen erfolgreich als veröffentlicht markiert." | |
msgid "Mark selected surveys as published" | ||
msgstr "Markiere ausgewählte Umfragen als veröffentlicht" | ||
|
||
#: survey/exporter/csv/survey2csv.py:33 | ||
#: survey/exporter/csv/survey2csv.py:35 | ||
msgid "Anonymous" | ||
msgstr "Anonym" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-01-26 18:37+0000\n" | ||
"POT-Creation-Date: 2020-02-05 22:05+0000\n" | ||
"PO-Revision-Date: 2018-04-01 11:49+0000\n" | ||
"Last-Translator: b' <>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -37,7 +37,7 @@ msgstr[1] "%(count)d questionnaires ont été publiés avec succès." | |
msgid "Mark selected surveys as published" | ||
msgstr "Marquer le sondage comme publié" | ||
|
||
#: survey/exporter/csv/survey2csv.py:33 | ||
#: survey/exporter/csv/survey2csv.py:35 | ||
msgid "Anonymous" | ||
msgstr "Anonyme" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-01-26 18:37+0000\n" | ||
"POT-Creation-Date: 2020-02-05 22:05+0000\n" | ||
"PO-Revision-Date: 2018-04-09 00:52+0000\n" | ||
"Last-Translator: b' <[email protected]>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -37,7 +37,7 @@ msgstr[1] "%(count)d つの調査が「公開」に設定されました" | |
msgid "Mark selected surveys as published" | ||
msgstr "選択した調査を公開する" | ||
|
||
#: survey/exporter/csv/survey2csv.py:33 | ||
#: survey/exporter/csv/survey2csv.py:35 | ||
msgid "Anonymous" | ||
msgstr "匿名" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: \n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-01-26 18:37+0000\n" | ||
"POT-Creation-Date: 2020-02-05 22:05+0000\n" | ||
"PO-Revision-Date: 2019-03-10 22:53+0230\n" | ||
"Last-Translator: b' <[email protected]>'\n" | ||
"Language-Team: \n" | ||
|
@@ -37,7 +37,7 @@ msgstr[1] "опросы %(count)d помечены как опубликован | |
msgid "Mark selected surveys as published" | ||
msgstr "Помечено как опублиовано" | ||
|
||
#: survey/exporter/csv/survey2csv.py:33 | ||
#: survey/exporter/csv/survey2csv.py:35 | ||
msgid "Anonymous" | ||
msgstr "Анонимно" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-01-26 18:37+0000\n" | ||
"POT-Creation-Date: 2020-02-05 22:05+0000\n" | ||
"PO-Revision-Date: 2018-04-09 00:52+0000\n" | ||
"Last-Translator: Zhu Sheng Li <[email protected]>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -37,7 +37,7 @@ msgstr[1] "%(count)d 件问卷成功标记为「已发布」" | |
msgid "Mark selected surveys as published" | ||
msgstr "标记选择的问卷为「已发布」" | ||
|
||
#: survey/exporter/csv/survey2csv.py:33 | ||
#: survey/exporter/csv/survey2csv.py:35 | ||
msgid "Anonymous" | ||
msgstr "匿名" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
|
||
from django.conf import settings | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
|
||
from survey.exporter.csv.survey2csv import Survey2Csv | ||
from survey.models import Survey | ||
|
||
|
||
class TestIssue70(TestCase): | ||
fixtures = [os.path.join(settings.ROOT, "survey", "tests", "issue70.json")] | ||
maxDiff = None | ||
|
||
def setUp(self): | ||
self.survey = Survey.objects.get(id=4) | ||
print(self.survey) | ||
self.s2csv = Survey2Csv(self.survey) | ||
header = ( | ||
"user,Email Address,Your Name,Date,STARTS Who? What? Where?,Donations,Books Sold,Your Total Volunteer hours" | ||
" for this week,Your Volunteer Activities this week.,Included in the above hours; how many of those above " | ||
"hours were on filing,New Hires,Charitable Donations,Events held What? Where? Products gotten?" | ||
) | ||
self.expected_content = """{} | ||
adminebd,[email protected],Ed Davison,2020-02-03,Left blank,0,0,8,['Admin'; 'Calls'; 'Events'],0,Left blank,100,""".format( | ||
header | ||
) | ||
|
||
@override_settings(USER_DID_NOT_ANSWER="Left blank") | ||
def test_get_survey_as_csv(self): | ||
self.assertEqual(self.s2csv.survey_to_x(), self.expected_content) | ||
|
||
@override_settings(USER_DID_NOT_ANSWER=None) | ||
def test_get_survey_as_csv_wrong_settings(self): | ||
with self.assertRaises(ImproperlyConfigured) as e: | ||
self.s2csv.survey_to_x() | ||
self.assertIn("USER_DID_NOT_ANSWER need to be set", str(e.exception)) |