Esempio n. 1
0
    def setUp(self):
        super(TestTaskSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory.create()
        self.task1 = TaskFactory.create(project=self.project)
        self.task2 = TaskFactory.create(project=self.project)
        self.task3 = TaskFactory.create(project=self.project)

        self.survey = SurveyFactory(title='test survey')

        self.project_response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )

        self.task_response1 = ResponseFactory.create(
            project=self.project,
            task=self.task1,
            survey=self.survey
        )

        self.task_response2 = ResponseFactory.create(
            project=self.project,
            task=self.task2,
            survey=self.survey
        )

        self.task_response3 = ResponseFactory.create(
            project=self.project,
            task=self.task3,
            survey=self.survey
        )
Esempio n. 2
0
    def setUp(self):
        super(TestTaskSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory.create()
        self.task1 = TaskFactory.create(project=self.project)
        self.task2 = TaskFactory.create(project=self.project)
        self.task3 = TaskFactory.create(project=self.project)

        self.survey = SurveyFactory(title='test survey')

        self.project_response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )

        self.task_response1 = ResponseFactory.create(
            project=self.project,
            task=self.task1,
            survey=self.survey
        )

        self.task_response2 = ResponseFactory.create(
            project=self.project,
            task=self.task2,
            survey=self.survey
        )

        self.task_response3 = ResponseFactory.create(
            project=self.project,
            task=self.task3,
            survey=self.survey
        )
Esempio n. 3
0
    def setUp(self):
        super(TestCombinedSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory.create()
        self.task1 = TaskFactory.create(project=self.project)
        self.task2 = TaskFactory.create(project=self.project)
        self.task3 = TaskFactory.create(project=self.project)

        self.survey = SurveyFactory(title='test survey')

        self.intitiator_response = ResponseFactory.create(
            project=self.project,
            user_type='initiator',
            survey=self.survey
        )

        self.organization_response = ResponseFactory.create(
            project=self.project,
            user_type='organization',
            survey=self.survey
        )

        self.task_response1 = ResponseFactory.create(
            project=self.project,
            task=self.task1,
            survey=self.survey
        )

        self.task_response2 = ResponseFactory.create(
            project=self.project,
            task=self.task2,
            survey=self.survey
        )

        self.task_response3 = ResponseFactory.create(
            project=self.project,
            task=self.task3,
            survey=self.survey
        )
Esempio n. 4
0
    def setUp(self):
        super(TestCombinedSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory.create()
        self.task1 = TaskFactory.create(project=self.project)
        self.task2 = TaskFactory.create(project=self.project)
        self.task3 = TaskFactory.create(project=self.project)

        self.survey = SurveyFactory(title='test survey')

        self.intitiator_response = ResponseFactory.create(
            project=self.project,
            user_type='initiator',
            survey=self.survey
        )

        self.organization_response = ResponseFactory.create(
            project=self.project,
            user_type='organization',
            survey=self.survey
        )

        self.task_response1 = ResponseFactory.create(
            project=self.project,
            task=self.task1,
            survey=self.survey
        )

        self.task_response2 = ResponseFactory.create(
            project=self.project,
            task=self.task2,
            survey=self.survey
        )

        self.task_response3 = ResponseFactory.create(
            project=self.project,
            task=self.task3,
            survey=self.survey
        )
Esempio n. 5
0
    def setUp(self):
        super(TestSimpleProjectSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory()
        self.project_2 = ProjectFactory()

        self.survey = SurveyFactory(title='test survey')

        self.response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )
Esempio n. 6
0
    def setUp(self):
        super(TestSimpleProjectSurveyAggregation, self).setUp()

        self.init_projects()

        self.project = ProjectFactory()
        self.project_2 = ProjectFactory()

        self.survey = SurveyFactory(title='test survey', active=True)

        self.response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )
Esempio n. 7
0
    def setUp(self):
        super(ProjectSurveyAPITestCase, self).setUp()

        self.init_projects()

        phase = ProjectPhase.objects.get(slug='campaign')

        self.project = ProjectFactory.create(status=phase)
        self.survey = SurveyFactory(title='test survey')

        questions = (
            ('Question 1', 'string', None, {}),
            ('Question 2', 'number', 'average', {'max_number': 100, 'min_number': 100}),
            ('Question 3', 'slider', 'sum', {'max_number': 100, 'min_number': 100})
        )

        questions = [
            QuestionFactory.create(
                survey=self.survey,
                title=title,
                type=type,
                aggregation=aggregation,
                properties=properties
            ) for title, type, aggregation, properties in questions]

        response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )

        for question in questions:
            AnswerFactory.create(
                question=question,
                response=response,
                value=random.randint(0, 100)
            )

        self.survey_url = reverse('project_survey_list')
Esempio n. 8
0
    def setUp(self):
        super(ProjectSurveyAPITestCase, self).setUp()

        self.init_projects()

        phase = ProjectPhase.objects.get(slug='campaign')

        self.project = ProjectFactory.create(status=phase)
        self.survey = SurveyFactory(title='test survey')

        questions = (('Question 1', 'string', None, {}),
                     ('Question 2', 'number', 'average', {
                         'max_number': 100,
                         'min_number': 100
                     }), ('Question 3', 'slider', 'sum', {
                         'max_number': 100,
                         'min_number': 100
                     }))

        questions = [
            QuestionFactory.create(survey=self.survey,
                                   title=title,
                                   type=type,
                                   aggregation=aggregation,
                                   properties=properties)
            for title, type, aggregation, properties in questions
        ]

        response = ResponseFactory.create(project=self.project,
                                          survey=self.survey)

        for question in questions:
            AnswerFactory.create(question=question,
                                 response=response,
                                 value=random.randint(0, 100))

        self.survey_url = reverse('project_survey_list')
Esempio n. 9
0
    def setUp(self):
        super(PlatformAggregateTest, self).setUp()
        now = timezone.now()
        last_year = now - datetime.timedelta(days=365)

        self.init_projects()

        survey = SurveyFactory.create()

        old_project = ProjectFactory.create(campaign_ended=last_year)
        new_project = ProjectFactory.create(campaign_ended=now)

        old_task1 = TaskFactory.create(project=old_project)
        old_task2 = TaskFactory.create(project=new_project)

        question1 = QuestionFactory.create(remote_id=1,
                                           type='number',
                                           survey=survey)
        question2 = QuestionFactory.create(remote_id=2,
                                           type='table-radio',
                                           survey=survey)
        SubQuestionFactory.create(question=question2, title='before')
        SubQuestionFactory.create(question=question2, title='after')
        question3 = QuestionFactory.create(remote_id=3,
                                           type='checkbox',
                                           survey=survey)
        question4 = QuestionFactory.create(remote_id=4,
                                           type='number',
                                           aggregation='average',
                                           survey=survey)

        for answer1, answer2, answer3, answer4 in ((4, {
                'before': 1,
                'after': 3
        }, {
                'test': 3,
                'tast': 4
        }, 62), (6, {
                'before': 3,
                'after': 5
        }, {
                'test': 4,
                'tast': 3
        }, 65), (8, {
                'before': 5,
                'after': 5
        }, {
                'test': 5,
                'tast': 5
        }, 55), (2, {
                'before': 7,
                'after': 3
        }, {
                'test': 6,
                'tast': 5
        }, 62)):
            response = ResponseFactory(project=old_project, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in (
            (2, {
                'before': 6,
                'after': 8
            }, {
                'test': 4,
                'tast': 5
            }, 60),
            (4, {
                'before': 2,
                'after': 4
            }, {
                'test': 4,
                'tast': 2
            }, 40),
        ):
            response = ResponseFactory(task=old_task1, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in (
            (11, {
                'before': 0,
                'after': 2
            }, {
                'test': 2,
                'tast': 3
            }, 12),
            (9, {
                'before': 2,
                'after': 4
            }, {
                'test': 4,
                'tast': 2
            }, 16),
        ):
            response = ResponseFactory(task=old_task2, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in ((3, {
                'before': 0,
                'after': 2
        }, {
                'test': 2,
                'tast': 3
        }, 23), (5, {
                'before': 2,
                'after': 4
        }, {
                'test': 4,
                'tast': 2
        }, 12), (7, {
                'before': 5,
                'after': 4
        }, {
                'test': 4,
                'tast': 5
        }, 14), (1, {
                'before': 6,
                'after': 2
        }, {
                'test': 5,
                'tast': 4
        }, 500)):
            response = ResponseFactory(project=new_project, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        survey.aggregate()