Ejemplo n.º 1
0
    def test_basic_submission_by_date(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        received_on = datetime(2013, 7, 15)

        self._send_form_to_es(received_on=received_on)
        self._send_form_to_es(received_on=received_on, xmlns=SYSTEM_FORM_XMLNS)

        results = get_submission_counts_by_date(self.domain,
                                                ['cruella_deville'],
                                                DateSpan(start, end), pytz.utc)
        self.assertEqual(results['2013-07-15'], 1)
Ejemplo n.º 2
0
    def test_basic_submission_by_date(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        received_on = datetime(2013, 7, 15)

        self._send_form_to_es(received_on=received_on)

        results = get_submission_counts_by_date(
            self.domain,
            ['cruella_deville'],
            DateSpan(start, end),
            pytz.utc
        )
        self.assertEquals(results['2013-07-15'], 1)
Ejemplo n.º 3
0
    def test_timezone_differences(self):
        """
        Our received_on dates are always in UTC, so if we submit a form right at midnight UTC, then the report
        should show that form being submitted the day before if viewing from an earlier timezone like New York
        """
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        received_on = datetime(2013, 7, 15, 0, 0, 0)
        timezone = pytz.timezone('America/New_York')

        self._send_form_to_es(received_on=received_on)

        results = get_submission_counts_by_date(self.domain,
                                                ['cruella_deville'],
                                                DateSpan(start, end), timezone)
        self.assertEqual(results['2013-07-14'], 1)
Ejemplo n.º 4
0
    def test_timezones_ahead_utc_in_get_submission_counts_by_date(self):
        """
        When bucketing form submissions, the returned bucket key needs to be converted to a datetime with
        the timezone specified. Specifically an issue for timezones ahead of UTC (positive offsets)
        """
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        received_on = datetime(2013, 7, 15)

        self._send_form_to_es(received_on=received_on)
        self._send_form_to_es(received_on=received_on, xmlns=SYSTEM_FORM_XMLNS)

        results = get_submission_counts_by_date(
            self.domain, ['cruella_deville'], DateSpan(start, end),
            pytz.timezone('Africa/Johannesburg'))
        self.assertEqual(results['2013-07-15'], 1)
Ejemplo n.º 5
0
    def test_timezone_differences(self):
        """
        Our received_on dates are always in UTC, so if we submit a form right at midnight UTC, then the report
        should show that form being submitted the day before if viewing from an earlier timezone like New York
        """
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        received_on = datetime(2013, 7, 15, 0, 0, 0)
        timezone = pytz.timezone('America/New_York')

        self._send_form_to_es(received_on=received_on)

        results = get_submission_counts_by_date(
            self.domain,
            ['cruella_deville'],
            DateSpan(start, end),
            timezone
        )
        self.assertEquals(results['2013-07-14'], 1)