def test_should_get_location_termly_data(self):
     self.water_source_poll.start()
     self.fake_incoming('yes',self.emis_reporter1)
     self.fake_incoming('yes',self.emis_reporter2)
     self.fake_incoming('no',self.emis_reporter3)
     location_result , monthly_result,percent = get_all_responses(self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn(('yes', 66), location_result)
     self.assertIn(('no', 33), location_result)
 def test_should_exclude_unknown_responses_for_pie(self):
     self.water_source_poll.start()
     self.fake_incoming('yes',self.emis_reporter1)
     self.fake_incoming('no',self.emis_reporter2)
     self.fake_incoming('unknown',self.emis_reporter3)
     location_result , monthly_result,percent = get_all_responses(self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn(('yes', 50), location_result)
     self.assertIn(('no', 50), location_result)
Example #3
0
 def test_should_exclude_unknown_responses_for_pie(self):
     self.water_source_poll.start()
     self.fake_incoming('yes', self.emis_reporter1)
     self.fake_incoming('no', self.emis_reporter2)
     self.fake_incoming('unknown', self.emis_reporter3)
     location_result, monthly_result, percent = get_all_responses(
         self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn(('yes', 50), location_result)
     self.assertIn(('no', 50), location_result)
Example #4
0
 def test_should_get_location_termly_data(self):
     self.water_source_poll.start()
     self.fake_incoming('yes', self.emis_reporter1)
     self.fake_incoming('yes', self.emis_reporter2)
     self.fake_incoming('no', self.emis_reporter3)
     location_result, monthly_result, percent = get_all_responses(
         self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn(('yes', 66), location_result)
     self.assertIn(('no', 33), location_result)
Example #5
0
def _get_poll_data_dict(location, poll, time_range):
    poll_data_dict = {}
    response, monthly_response, percent = get_all_responses(poll, location, time_range)
    categories, data = get_categories_and_data(monthly_response)
    poll_data_dict['response'] = response
    poll_data_dict['categories'] = categories
    poll_data_dict['data'] = data
    poll_data_dict['label'] = get_label_for_poll(poll)
    poll_data_dict['school_percent'] = percent
    return poll_data_dict
 def test_should_exclude_unknown_responses_for_bar_graph(self):
     self.water_source_poll.start()
     self.fake_incoming('yes',self.emis_reporter1)
     self.fake_incoming('no',self.emis_reporter2)
     self.fake_incoming('i dont know',self.emis_reporter3)
     responses = self.water_source_poll.responses.all()
     for response in responses:
         self.set_response_date(date.today(), response)
     location_result, monthly_result,percent = get_all_responses(self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn((datetime.today().strftime("%B"),{'yes':50,'no':50}), monthly_result)
 def test_should_responses_for_current_term_only(self):
     settings.SCHOOL_TERM_START = dateutils.increment(datetime.now(),weeks=-16)
     settings.SCHOOL_TERM_END = dateutils.increment(datetime.now(),weeks=-4)
     term_range = [settings.SCHOOL_TERM_START,settings.SCHOOL_TERM_END]
     self.water_source_poll.start()
     self.fake_incoming('yes',self.emis_reporter1)
     self.fake_incoming('yes',self.emis_reporter2)
     self.fake_incoming('no',self.emis_reporter3)
     location_result , monthly_result,percent = get_all_responses(self.water_source_poll, [self.kampala_district], term_range)
     self.assertEqual([],location_result)
Example #8
0
def _get_poll_data_dict(location, poll, time_range):
    poll_data_dict = {}
    response, monthly_response, percent = get_all_responses(
        poll, location, time_range)
    categories, data = get_categories_and_data(monthly_response)
    poll_data_dict['response'] = response
    poll_data_dict['categories'] = categories
    poll_data_dict['data'] = data
    poll_data_dict['label'] = get_label_for_poll(poll)
    poll_data_dict['school_percent'] = percent
    return poll_data_dict
    def test_should_get_monthly_data(self):
        self.water_source_poll.start()
        self.fake_incoming('yes',self.emis_reporter1)
        self.fake_incoming('yes',self.emis_reporter2)
        self.fake_incoming('no',self.emis_reporter3)

        for (i,response) in enumerate(self.water_source_poll.responses.all().order_by('id')):
            self.set_response_date(datetime(2012, i+2, i+2), response)

        location_result,monthly_result,percent = get_all_responses(self.water_source_poll, [self.kampala_district], (datetime(2012, 1, 1), datetime(2012, 5, 5)))
        self.assertIn(("February",{'yes':100}), monthly_result)
        self.assertIn(("April",{'no':100}), monthly_result)
Example #10
0
 def test_should_responses_for_current_term_only(self):
     settings.SCHOOL_TERM_START = dateutils.increment(datetime.now(),
                                                      weeks=-16)
     settings.SCHOOL_TERM_END = dateutils.increment(datetime.now(),
                                                    weeks=-4)
     term_range = [settings.SCHOOL_TERM_START, settings.SCHOOL_TERM_END]
     self.water_source_poll.start()
     self.fake_incoming('yes', self.emis_reporter1)
     self.fake_incoming('yes', self.emis_reporter2)
     self.fake_incoming('no', self.emis_reporter3)
     location_result, monthly_result, percent = get_all_responses(
         self.water_source_poll, [self.kampala_district], term_range)
     self.assertEqual([], location_result)
Example #11
0
 def test_should_exclude_unknown_responses_for_bar_graph(self):
     self.water_source_poll.start()
     self.fake_incoming('yes', self.emis_reporter1)
     self.fake_incoming('no', self.emis_reporter2)
     self.fake_incoming('i dont know', self.emis_reporter3)
     responses = self.water_source_poll.responses.all()
     for response in responses:
         self.set_response_date(date.today(), response)
     location_result, monthly_result, percent = get_all_responses(
         self.water_source_poll, [self.kampala_district], self.term_range)
     self.assertIn((datetime.today().strftime("%B"), {
         'yes': 50,
         'no': 50
     }), monthly_result)
Example #12
0
    def test_should_get_monthly_data(self):
        self.water_source_poll.start()
        self.fake_incoming('yes', self.emis_reporter1)
        self.fake_incoming('yes', self.emis_reporter2)
        self.fake_incoming('no', self.emis_reporter3)

        for (i, response) in enumerate(
                self.water_source_poll.responses.all().order_by('id')):
            self.set_response_date(datetime(2012, i + 2, i + 2), response)

        location_result, monthly_result, percent = get_all_responses(
            self.water_source_poll, [self.kampala_district],
            (datetime(2012, 1, 1), datetime(2012, 5, 5)))
        self.assertIn(("February", {'yes': 100}), monthly_result)
        self.assertIn(("April", {'no': 100}), monthly_result)