Example #1
0
    def test_group_week(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 15)]
        expected_days = [datetime.date(2012, 5, 8)]

        dummies = pad_missing_stats(days, 'week')
        for day in expected_days:
            assert day in [dummy['date'] for dummy in dummies]
Example #2
0
    def test_group_month(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 7, 1)]
        expected_days = [datetime.date(2012, 6, 1)]

        dummies = pad_missing_stats(days, 'month')
        for day in expected_days:
            assert day in [dummy['date'] for dummy in dummies]
Example #3
0
    def test_group_month(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 7, 1)]
        expected_days = [datetime.date(2012, 6, 1)]

        dummies = pad_missing_stats(days, "month")
        for day in expected_days:
            assert day in [dummy["date"] for dummy in dummies]
Example #4
0
    def test_group_week(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 15)]
        expected_days = [datetime.date(2012, 5, 8)]

        dummies = pad_missing_stats(days, "week")
        for day in expected_days:
            assert day in [dummy["date"] for dummy in dummies]
Example #5
0
    def test_group_month(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 7, 1)]
        expected_days = [datetime.date(2012, 6, 1)]

        dummies = pad_missing_stats(days, 'month')
        days = [dummy['date'].date() for dummy in dummies]
        for day in expected_days:
            eq_(day in days, True)
Example #6
0
    def test_group_week(self):
        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 15)]
        expected_days = [datetime.date(2012, 5, 8)]

        dummies = pad_missing_stats(days, 'week')
        days = [dummy['date'].date() for dummy in dummies]
        for day in expected_days:
            eq_(day in days, True)
Example #7
0
    def test_with_fields(self):
        fields = ['test_field', 'fest_tield']

        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 3)]
        dummies = pad_missing_stats(days, 'day', fields=fields)
        for dummy in dummies:
            for field in fields:
                eq_(field in dummy, True)
Example #8
0
    def test_with_fields(self):
        fields = ['test_field', 'fest_tield']

        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 3)]
        dummies = pad_missing_stats(days, 'day', fields=fields)
        for dummy in dummies:
            for field in fields:
                eq_(field in dummy, True)
Example #9
0
    def test_with_fields(self):
        fields = ["test_field", "fest_tield"]

        days = [datetime.date(2012, 5, 1), datetime.date(2012, 5, 3)]
        dummies = pad_missing_stats(days, "day", fields=fields)
        for dummy in dummies:
            for field in fields:
                assert field in dummy
Example #10
0
    def test_with_date_range(self):
        date_range = (datetime.date(2012, 5, 1), datetime.date(2012, 5, 5))

        days = [datetime.date(2012, 5, 3)]
        expected_days = [datetime.date(2012, 5, 2), datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, 'day', date_range=date_range)
        for day in expected_days:
            assert day in [dummy['date'] for dummy in dummies]
Example #11
0
    def test_with_date_range(self):
        date_range = (datetime.date(2012, 5, 1), datetime.date(2012, 5, 5))

        days = [datetime.date(2012, 5, 3)]
        expected_days = [datetime.date(2012, 5, 2), datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, "day", date_range=date_range)
        for day in expected_days:
            assert day in [dummy["date"] for dummy in dummies]
Example #12
0
    def test_with_date_range(self):
        date_range = (datetime.date(2012, 5, 1), datetime.date(2012, 5, 5))

        days = [datetime.date(2012, 5, 3)]
        expected_days = [datetime.date(2012, 5, 2), datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, 'day', date_range=date_range)
        days = [dummy['date'].date() for dummy in dummies]
        for day in expected_days:
            eq_(day in days, True)
Example #13
0
    def test_basic(self):
        days = [datetime.date(2012, 4, 29), datetime.date(2012, 5, 1),
                datetime.date(2012, 5, 3), datetime.date(2012, 5, 5)]
        expected_days = [datetime.date(2012, 4, 30), datetime.date(2012, 5, 2),
                         datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, 'day')
        days = [dummy['date'].date() for dummy in dummies]
        for day in expected_days:
            eq_(day in days, True)
Example #14
0
    def test_basic(self):
        days = [datetime.date(2012, 4, 29), datetime.date(2012, 5, 1),
                datetime.date(2012, 5, 3), datetime.date(2012, 5, 5)]
        expected_days = [datetime.date(2012, 4, 30), datetime.date(2012, 5, 2),
                         datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, 'day')
        days = [dummy['date'].date() for dummy in dummies]
        for day in expected_days:
            eq_(day in days, True)
Example #15
0
    def test_basic(self):
        days = [
            datetime.date(2012, 4, 29),
            datetime.date(2012, 5, 1),
            datetime.date(2012, 5, 3),
            datetime.date(2012, 5, 5),
        ]
        expected_days = [datetime.date(2012, 4, 30), datetime.date(2012, 5, 2), datetime.date(2012, 5, 4)]

        dummies = pad_missing_stats(days, "day")
        for day in expected_days:
            assert day in [dummy["date"] for dummy in dummies]