|
11 | 11 | import SORT.test.model_factory |
12 | 12 | import SORT.test.test_case |
13 | 13 | from home.constants import ROLE_ADMIN |
14 | | -from survey.models import Invitation, Survey |
| 14 | +from survey.models import Invitation, Survey, SurveyEvidenceSection, SurveyImprovementPlanSection |
15 | 15 | from survey.services import SurveyService |
16 | 16 |
|
17 | 17 |
|
@@ -115,6 +115,23 @@ def test_update_consent_demography_config(self): |
115 | 115 | "Unexpected demography sections", |
116 | 116 | ) |
117 | 117 |
|
| 118 | + def test_duplicate_survey(self): |
| 119 | + # Properly initialise the survey |
| 120 | + self.service.initialise_survey(self.admin, self.project, self.survey) |
| 121 | + self.service.update_consent_demography_config(self.admin, self.survey, |
| 122 | + demography_config=self.survey.demography_config, |
| 123 | + survey_body_path=self.survey.survey_body_path, |
| 124 | + consent_config=self.survey.consent_config) |
| 125 | + |
| 126 | + duplicated_survey = self.service.duplicate_survey(user=self.admin, survey=self.survey) |
| 127 | + self.assertTrue(duplicated_survey.name.startswith("Copy of")) |
| 128 | + self.assertEqual(duplicated_survey.project, self.survey.project) |
| 129 | + self.assertDictEqual(duplicated_survey.survey_config, self.survey.survey_config) |
| 130 | + self.assertDictEqual(duplicated_survey.consent_config, self.survey.consent_config) |
| 131 | + self.assertDictEqual(duplicated_survey.demography_config, self.survey.demography_config) |
| 132 | + self.assertTrue(SurveyEvidenceSection.objects.filter(survey=duplicated_survey).count() > 1) |
| 133 | + self.assertTrue(SurveyImprovementPlanSection.objects.filter(survey=duplicated_survey).count() > 1) |
| 134 | + |
118 | 135 | def test_get_survey_from_token(self): |
119 | 136 | token = self.survey.current_invite_token() |
120 | 137 | self.assertIsInstance(token, str) |
|
0 commit comments