Пример #1
0
 def test_update_question_order_page(self):
     listing_form = ListingTemplate.objects.create(name='l12', description='desc1')
     kwargs = {'name': 'survey11', 'description': 'survey description demo12',
                       'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
     survey_obj = Survey.objects.create(**kwargs)
     batch_obj = Batch.objects.create(name='b1',description='d1', survey=survey_obj)
     qset = QuestionSet.get(id=batch_obj.id)
     question1 = mommy.make(Question, qset=qset, answer_type=NumericalAnswer.choice_name())
     QuestionOption.objects.create(
         question=question1,
         order=1,
         text="q7"
         ) 
     question2 = mommy.make(Question, qset=qset, answer_type=NumericalAnswer.choice_name())
     QuestionOption.objects.create(
         question=question1,
         order=4,
         text="q4"
         )
     QuestionFlow.objects.create(
         name = 'a1',
         desc = 'descq',
         question = question2,
         question_type = TextAnswer.choice_name(),
         next_question = question1,
         next_question_type = TextAnswer.choice_name()
         )
     QuestionLoop.objects.create(
         loop_starter = question2,
         loop_ender = question1
         )
     
     url = reverse('update_question_order_page', kwargs={"batch_id" : batch_obj.id})
     response = self.client.post(url,data={"order_information": [batch_obj.id]})
     self.assertIn(response.status_code, [200, 302])
Пример #2
0
 def test_list_batches(self):
     survey_obj = Survey.objects.create(name="s21111", description="desc1")
     batch_obj = Batch.objects.create(order=1, name="b21", description='bdesc' ,survey=survey_obj)
     qset =  QuestionSet.get(pk=batch_obj.id)
     question1 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     question2 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     url = reverse('list_batches')
     response = self.client.get(url)
     self.assertIn(response.status_code, [200, 302])
     response = self.client.get(reverse('survey_list_page'))
Пример #3
0
 def test_batch_check_name(self):
     survey_obj = Survey.objects.create(name="s21111", description="desc1")
     batch_obj = Batch.objects.create(order=1, name="b21", description='bdesc' ,survey=survey_obj)
     qset =  QuestionSet.get(pk=batch_obj.id)
     question1 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     question2 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     url = reverse('check_batches_name', kwargs={"survey_id":survey_obj.id})
     url = url+"?name=%s"%batch_obj.name
     response = self.client.get(url)
     self.assertIn(response.status_code, [200, 302])
Пример #4
0
 def test_list_batch_questions(self):
     survey_obj = Survey.objects.create(name="s21111", description="desc1")
     batch_obj = Batch.objects.create(order=1, name="b21", description='bdesc' ,survey=survey_obj)
     qset =  QuestionSet.get(pk=batch_obj.id)
     question1 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     question2 = mommy.make(Question, qset=qset, answer_type=TextAnswer.choice_name())
     url = reverse('list_all_questions')
     url = url + "?id=%s"%batch_obj.id
     response = self.client.get(url, data={"id": batch_obj.id})
     self.assertIn(response.status_code, [200, 302])
     response = self.client.get(reverse('batch_index_page', kwargs={"survey_id" : survey_obj.id}))
Пример #5
0
 def test_batch_show_page(self):
     listing_form = ListingTemplate.objects.create(name='l121', description='desc1')
     kwargs = {'name': 'survey11demo23', 'description': 'survey description demo12',
                       'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
     survey_obj = Survey.objects.create(**kwargs)
     batch_obj = Batch.objects.create(name='b132',description='d1', survey=survey_obj)
     qset = QuestionSet.get(id=batch_obj.id)
     
     url = reverse('batch_show_page', kwargs={"batch_id" : batch_obj.id, "survey_id" :survey_obj.id})
     url = url + "?q=%s"%batch_obj.name
     response = self.client.get(url, data={"status" : "Open"})
     self.assertIn(response.status_code, [200, 302])
Пример #6
0
 def test_batch_open_page(self):
     listing_form = ListingTemplate.objects.create(name='l12', description='desc1')
     kwargs = {'name': 'survey11', 'description': 'survey description demo12',
                       'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
     survey_obj = Survey.objects.create(**kwargs)
     batch_obj = Batch.objects.create(name='b1',description='d1', survey=survey_obj)
     qset = QuestionSet.get(id=batch_obj.id)
     
     url = reverse('batch_open_page', kwargs={"batch_id" : batch_obj.id})
     response = self.client.post(url, data={"location_id" : self.abim.id})
     self.assertIn(response.status_code, [200, 302])
     self.assertEqual("", "")
Пример #7
0
 def test_update_question_order_page_on_empty(self):
     listing_form = ListingTemplate.objects.create(name='l12', description='desc1')
     kwargs = {'name': 'survey11', 'description': 'survey description demo12',
                       'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
     survey_obj = Survey.objects.create(**kwargs)
     batch_obj = Batch.objects.create(name='b1',description='d1', survey=survey_obj)
     qset = QuestionSet.get(id=batch_obj.id)
     
     url = reverse('update_question_order_page', kwargs={"batch_id" : batch_obj.id})
     response = self.client.post(url,data={"order_information": []})
     self.assertIn(response.status_code, [200, 302])
     self.assertIn("No questions orders were updated.", response.cookies['messages'].__str__())
Пример #8
0
    def test_batch_all_locs(self):
        listing_form = ListingTemplate.objects.create(name='l12', description='desc1')
        kwargs = {'name': 'survey11demo', 'description': 'survey description demo12',
                          'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b14',description='d1', survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)
        
        url = reverse('batch_all_locs', kwargs={"batch_id" : batch_obj.id})
        response = self.client.post(url, data={"action" : "open all"})
        self.assertIn(response.status_code, [200, 302])
        

        
        listing_form = ListingTemplate.objects.create(name='l121', description='desc1')
        kwargs = {'name': 'survey11demo1', 'description': 'survey description demo12',
                          'has_sampling': True, 'sample_size': 10,'listing_form_id':listing_form.id}
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b133',description='d1', survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)
        url = reverse('batch_all_locs', kwargs={"batch_id" : batch_obj.id})
        response = self.client.post(url, data={"action" : "close all"})
        self.assertIn(response.status_code, [200, 302])
Пример #9
0
    def test_batch_all_locs(self):
        listing_form = ListingTemplate.objects.create(name='l12',
                                                      description='desc1')
        kwargs = {
            'name': 'survey11demo',
            'description': 'survey description demo12',
            'has_sampling': True,
            'sample_size': 10,
            'listing_form_id': listing_form.id
        }
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b14',
                                         description='d1',
                                         survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)

        url = reverse('batch_all_locs', kwargs={"batch_id": batch_obj.id})
        response = self.client.post(url, data={"action": "open all"})
        self.assertIn(response.status_code, [200, 302])

        listing_form = ListingTemplate.objects.create(name='l121',
                                                      description='desc1')
        kwargs = {
            'name': 'survey11demo1',
            'description': 'survey description demo12',
            'has_sampling': True,
            'sample_size': 10,
            'listing_form_id': listing_form.id
        }
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b133',
                                         description='d1',
                                         survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)
        url = reverse('batch_all_locs', kwargs={"batch_id": batch_obj.id})
        response = self.client.post(url, data={"action": "close all"})
        self.assertIn(response.status_code, [200, 302])
Пример #10
0
 def test_list_batches(self):
     survey_obj = Survey.objects.create(name="s21111", description="desc1")
     batch_obj = Batch.objects.create(order=1,
                                      name="b21",
                                      description='bdesc',
                                      survey=survey_obj)
     qset = QuestionSet.get(pk=batch_obj.id)
     question1 = mommy.make(Question,
                            qset=qset,
                            answer_type=TextAnswer.choice_name())
     question2 = mommy.make(Question,
                            qset=qset,
                            answer_type=TextAnswer.choice_name())
     url = reverse('list_batches')
     response = self.client.get(url)
     self.assertIn(response.status_code, [200, 302])
     response = self.client.get(reverse('survey_list_page'))
Пример #11
0
 def test_batch_check_name(self):
     survey_obj = Survey.objects.create(name="s21111", description="desc1")
     batch_obj = Batch.objects.create(order=1,
                                      name="b21",
                                      description='bdesc',
                                      survey=survey_obj)
     qset = QuestionSet.get(pk=batch_obj.id)
     question1 = mommy.make(Question,
                            qset=qset,
                            answer_type=TextAnswer.choice_name())
     question2 = mommy.make(Question,
                            qset=qset,
                            answer_type=TextAnswer.choice_name())
     url = reverse('check_batches_name',
                   kwargs={"survey_id": survey_obj.id})
     url = url + "?name=%s" % batch_obj.name
     response = self.client.get(url)
     self.assertIn(response.status_code, [200, 302])
Пример #12
0
    def test_batch_open_page(self):
        listing_form = ListingTemplate.objects.create(name='l12',
                                                      description='desc1')
        kwargs = {
            'name': 'survey11',
            'description': 'survey description demo12',
            'has_sampling': True,
            'sample_size': 10,
            'listing_form_id': listing_form.id
        }
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b1',
                                         description='d1',
                                         survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)

        url = reverse('batch_open_page', kwargs={"batch_id": batch_obj.id})
        response = self.client.post(url, data={"location_id": self.abim.id})
        self.assertIn(response.status_code, [200, 302])
        self.assertEqual("", "")
Пример #13
0
    def test_batch_show_page(self):
        listing_form = ListingTemplate.objects.create(name='l121',
                                                      description='desc1')
        kwargs = {
            'name': 'survey11demo23',
            'description': 'survey description demo12',
            'has_sampling': True,
            'sample_size': 10,
            'listing_form_id': listing_form.id
        }
        survey_obj = Survey.objects.create(**kwargs)
        batch_obj = Batch.objects.create(name='b132',
                                         description='d1',
                                         survey=survey_obj)
        qset = QuestionSet.get(id=batch_obj.id)

        url = reverse('batch_show_page',
                      kwargs={
                          "batch_id": batch_obj.id,
                          "survey_id": survey_obj.id
                      })
        url = url + "?q=%s" % batch_obj.name
        response = self.client.get(url, data={"status": "Open"})
        self.assertIn(response.status_code, [200, 302])
Пример #14
0
 def qset(self):
     from survey.models.questions import QuestionSet
     return QuestionSet.get(pk=self.question_set.pk)
Пример #15
0
 def eqset(self):
     """Returns the exactt question set for this indicator
     :return:
     """
     return QuestionSet.get(id=self.question_set.id)
Пример #16
0
 def qset(self):
     from survey.models.questions import QuestionSet
     return QuestionSet.get(pk=self.question_set.pk)