def test_should_give_proper_month_data_starting_from_today(self):
        start_date = datetime(2012, 1, 1)
        end_date = dateutils.increment(start_date, weeks=10)

        months = get_months(start_date, end_date)
        self.assertEqual(months[0][0].date(), start_date.date())
        self.assertEqual(months[-1][1].date(), end_date.date())
示例#2
0
    def test_should_give_proper_month_data_starting_from_today(self):
        start_date = datetime(2012, 1, 1)
        end_date = dateutils.increment(start_date, weeks=10)

        months = get_months(start_date, end_date)
        self.assertEqual(months[0][0].date(), start_date.date())
        self.assertEqual(months[-1][1].date(), end_date.date())
def get_all_responses(poll, location, time_range):
    unknown_responses = poll.responses.filter(categories__category__name='unknown')
    all_responses = poll.responses_by_category().filter(response__contact__reporting_location__in=location).exclude(response__in=unknown_responses)
    term_responses = all_responses.filter(response__date__range = time_range)
    percent_of_schools = get_reporting_school_percentage(term_responses,location)
    months= get_months(time_range[0],time_range[1])
    months.reverse()
    monthly_result = [_format_to_ret_for_all_responses(month, all_responses)for month in months]
    #       dictionary of category and percent, tuple of month and dict, percentage for a school
    return _extract_percentage_for_each_response_category_from(term_responses).items(), monthly_result, percent_of_schools
示例#4
0
def get_all_responses(poll, location, time_range):
    unknown_responses = poll.responses.filter(
        categories__category__name='unknown')
    all_responses = poll.responses_by_category().filter(
        response__contact__reporting_location__in=location).exclude(
            response__in=unknown_responses)
    term_responses = all_responses.filter(response__date__range=time_range)
    percent_of_schools = get_reporting_school_percentage(
        term_responses, location)
    months = get_months(time_range[0], time_range[1])
    months.reverse()
    monthly_result = [
        _format_to_ret_for_all_responses(month, all_responses)
        for month in months
    ]
    #       dictionary of category and percent, tuple of month and dict, percentage for a school
    return _extract_percentage_for_each_response_category_from(
        term_responses).items(), monthly_result, percent_of_schools