示例#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
    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
    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
    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
    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
    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
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
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
    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
 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
    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
    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
 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
    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
 def test_start_of_month_is_valid(self):
     assert_that(MONTH.valid_start_at(d(2013, 4, 1, 0, 0, 0)), is_(True))