コード例 #1
0
    def test_that_it_returns_the_end_of_the_current_month(self):
        some_datetime = d(2013, 10, 4, 10, 23, 43)
        some_other_datetime = d(2013, 10, 4)

        end = MONTH.end(some_datetime)
        other_end = MONTH.end(some_other_datetime)

        assert_that(end, is_(d(2013, 11, 1)))
        assert_that(other_end, is_(d(2013, 11, 1)))
コード例 #2
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_returns_the_end_of_the_current_month(self):
        some_datetime = d(2013, 10, 4, 10, 23, 43)
        some_other_datetime = d(2013, 10, 4)

        end = MONTH.end(some_datetime)
        other_end = MONTH.end(some_other_datetime)

        assert_that(end, is_(d(2013, 11, 1)))
        assert_that(other_end, is_(d(2013, 11, 1)))
コード例 #3
0
    def test_that_it_produces_a_sequence_of_monthly_time_periods(self):
        range = MONTH.range(d_tz(2013, 4, 1), d_tz(2013, 6, 1))

        assert_that(list(range), contains(
            (d_tz(2013, 4, 1), d_tz(2013, 5, 1)),
            (d_tz(2013, 5, 1), d_tz(2013, 6, 1))
        ))
コード例 #4
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_expands_the_limits_of_the_range_if_midmonth(self):
        range = MONTH.range(d_tz(2013, 4, 3), d_tz(2013, 5, 19))

        assert_that(list(range), contains(
            (d_tz(2013, 4, 1), d_tz(2013, 5, 1)),
            (d_tz(2013, 5, 1), d_tz(2013, 6, 1)),
        ))
コード例 #5
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_produces_a_sequence_of_monthly_time_periods(self):
        range = MONTH.range(d_tz(2013, 4, 1), d_tz(2013, 6, 1))

        assert_that(list(range), contains(
            (d_tz(2013, 4, 1), d_tz(2013, 5, 1)),
            (d_tz(2013, 5, 1), d_tz(2013, 6, 1))
        ))
コード例 #6
0
    def test_that_it_expands_the_limits_of_the_range_if_midmonth(self):
        range = MONTH.range(d_tz(2013, 4, 3), d_tz(2013, 5, 19))

        assert_that(list(range), contains(
            (d_tz(2013, 4, 1), d_tz(2013, 5, 1)),
            (d_tz(2013, 5, 1), d_tz(2013, 6, 1)),
        ))
コード例 #7
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_returns_same_day_for_first_of_month_midnight(self):
        some_datetime = datetime.datetime(
            year=2013, month=11, day=1, hour=0, minute=0, second=0,
            microsecond=0)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(some_datetime))
コード例 #8
0
    def test_that_it_returns_same_day_for_first_of_month_midnight(self):
        some_datetime = datetime.datetime(
            year=2013, month=11, day=1, hour=0, minute=0, second=0,
            microsecond=0)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(some_datetime))
コード例 #9
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 5, 7, 10, 12, 13)

        start = MONTH.start(some_datetime)

        assert_that(start.hour, is_(0))
        assert_that(start.minute, is_(0))
        assert_that(start.second, is_(0))
        assert_that(start.microsecond, is_(0))
コード例 #10
0
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 5, 7, 10, 12, 13)

        start = MONTH.start(some_datetime)

        assert_that(start.hour, is_(0))
        assert_that(start.minute, is_(0))
        assert_that(start.second, is_(0))
        assert_that(start.microsecond, is_(0))
コード例 #11
0
    def __init__(self, data):
        result = validate_record_data(data)
        if not result.is_valid:
            raise ValidationError(result.message)

        self.data = data
        self.meta = {}

        if "_timestamp" in self.data:
            self.meta['_week_start_at'] = WEEK.start(self.data['_timestamp'])
            self.meta['_month_start_at'] = MONTH.start(self.data['_timestamp'])
コード例 #12
0
ファイル: test_nested_merge.py プロジェクト: pwaller/backdrop
def datum(name=None, place=None, age=None, stamp=None, count=1):
    result = {
        "_count": count
    }
    if name is not None:
        result['name'] = name
    if place is not None:
        result['place'] = place
    if age is not None:
        result['age'] = age
    if stamp is not None:
        result['_timestamp'] = stamp
        result['_week_start_at'] = WEEK.start(stamp)
        result['_month_start_at'] = MONTH.start(stamp)
    return result
コード例 #13
0
def datum(name=None, version=None, place=None, age=None, stamp=None, count=1):
    result = {"_count": count}
    if name is not None:
        result['name'] = name
    if version is not None:
        result['version'] = version
    if place is not None:
        result['place'] = place
    if age is not None:
        result['age'] = age
    if stamp is not None:
        result['_timestamp'] = stamp
        result['_week_start_at'] = WEEK.start(stamp)
        result['_month_start_at'] = MONTH.start(stamp)
    return result
コード例 #14
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_returns_the_next_month_for_boundary_after_midnight(self):
        some_datetime = d(2013, 5, 1, 0, 12)

        end = MONTH.end(some_datetime)

        assert_that(end, is_(d(2013, 6, 1)))
コード例 #15
0
    def test_that_it_returns_same_day_for_first_of_month(self):
        some_datetime = d(2013, 12, 1, 12, 32, 34)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 12, 1)))
コード例 #16
0
ファイル: test_timeseries.py プロジェクト: NRCan/backdrop
 def test_start_of_month_plus_second_is_invalid(self):
     assert_that(MONTH.valid_start_at(d(2013, 4, 1, 0, 0, 1)), is_(False))
コード例 #17
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 4, 9, 23, 12)

        end = MONTH.end(some_datetime)

        assert_that(end, is_(d(2013, 5, 1)))
コード例 #18
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_returns_same_day_for_first_of_month(self):
        some_datetime = d(2013, 12, 1, 12, 32, 34)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 12, 1)))
コード例 #19
0
ファイル: test_timeseries.py プロジェクト: NRCan/backdrop
 def test_start_of_month_plus_day_is_invalid(self):
     assert_that(MONTH.valid_start_at(d(2013, 4, 2, 0, 0, 0)), is_(False))
コード例 #20
0
    def test_that_it_truncates_the_time_part(self):
        some_datetime = d(2013, 4, 9, 23, 12)

        end = MONTH.end(some_datetime)

        assert_that(end, is_(d(2013, 5, 1)))
コード例 #21
0
ファイル: test_timeseries.py プロジェクト: frabcus/backdrop
    def test_that_it_returns_first_of_current_month_for_midmonth(self):
        some_datetime = d(2013, 4, 9)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 4, 1)))
コード例 #22
0
    def test_that_it_returns_first_of_current_month_for_midmonth(self):
        some_datetime = d(2013, 4, 9)

        start = MONTH.start(some_datetime)

        assert_that(start, is_(d(2013, 4, 1)))
コード例 #23
0
    def test_that_it_returns_the_next_month_for_boundary_after_midnight(self):
        some_datetime = d(2013, 5, 1, 0, 12)

        end = MONTH.end(some_datetime)

        assert_that(end, is_(d(2013, 6, 1)))
コード例 #24
0
ファイル: test_timeseries.py プロジェクト: NRCan/backdrop
 def test_start_of_month_is_valid(self):
     assert_that(MONTH.valid_start_at(d(2013, 4, 1, 0, 0, 0)), is_(True))