Пример #1
0
async def test_mdinterval_reversed(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month + 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month - 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day, '')
    ]).eval(context={})
    assert result == 0
Пример #2
0
async def test_bow_sunday_positive(freezer, dummy_local_datetime, local_tz_info):
    freezer.move_to(dummy_local_datetime)
    result = await date.BOWFunction([
        literalvalues.LiteralValue(54, ''),
        literalvalues.LiteralValue(6, '')
    ]).eval(context={})

    dt = datetime.datetime(2020, 3, 22, 0, 0, 0)
    dt = dt.astimezone(local_tz_info)
    assert result == dt.timestamp()
Пример #3
0
async def test_bow_sunday_negative(freezer, dummy_local_datetime,
                                   local_tz_info):
    freezer.move_to(dummy_local_datetime)
    result = await date.BOWFunction([
        literalvalues.LiteralValue(-54, ''),
        literalvalues.LiteralValue(6, '')
    ]).eval()

    dt = datetime.datetime(2018, 2, 25, 0, 0, 0)
    dt = dt.astimezone(local_tz_info)
    assert result == dt.timestamp()
Пример #4
0
async def test_bow_sunday(freezer, dummy_local_datetime, literal_zero,
                          local_tz_info):
    freezer.move_to(dummy_local_datetime)
    result = await date.BOWFunction(
        [literal_zero, literalvalues.LiteralValue(6, '')]).eval()

    dt = dummy_local_datetime.replace(day=dummy_local_datetime.day -
                                      dummy_local_datetime.weekday() - 1,
                                      hour=0,
                                      minute=0,
                                      second=0,
                                      microsecond=0)
    dt = dt.astimezone(local_tz_info)
    assert result == dt.timestamp()
Пример #5
0
async def test_bom_positive(freezer, dummy_local_datetime, dummy_timestamp, local_tz_info):
    freezer.move_to(dummy_local_datetime)
    result = await date.BOMFunction([literalvalues.LiteralValue(13, '')]).eval(context={})

    dt = dummy_local_datetime.replace(
        year=dummy_local_datetime.year + 1,
        month=dummy_local_datetime.month + 1,
        day=1,
        hour=0,
        minute=0,
        second=0,
        microsecond=0
    )
    dt = dt.astimezone(local_tz_info)
    assert result == dt.timestamp()
Пример #6
0
async def test_mdinterval_limit(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day + 1, '')
    ]).eval()
    assert result == 1

    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day - 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day, '')
    ]).eval()
    assert result == 1
Пример #7
0
async def test_date(dummy_local_datetime, dummy_timestamp):
    result = await date.DateFunction([
        literalvalues.LiteralValue(dummy_local_datetime.year, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month, ''),
        literalvalues.LiteralValue(dummy_local_datetime.day, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second, '')
    ]).eval(context={})
    assert result == int(dummy_timestamp)
Пример #8
0
async def test_hmsinterval_reversed(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour + 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour - 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second, '')
    ]).eval(context={})
    assert result == 0
Пример #9
0
def literal_minus_pi():
    return literalvalues.LiteralValue(-3.14159, '-3.14159')
Пример #10
0
def literal_minus_two():
    return literalvalues.LiteralValue(-2, '-2')
Пример #11
0
def literal_minus_one():
    return literalvalues.LiteralValue(-1, '-1')
Пример #12
0
def literal_one_thousand():
    return literalvalues.LiteralValue(1000, '1000')
Пример #13
0
def literal_true():
    return literalvalues.LiteralValue(True, 'true')
Пример #14
0
def literal_zero_point_five():
    return literalvalues.LiteralValue(0.5, '0.5')
Пример #15
0
def literal_sixteen():
    return literalvalues.LiteralValue(16, '16')
Пример #16
0
def literal_ten_point_fifty_one():
    return literalvalues.LiteralValue(10.51, '10.51')
Пример #17
0
def literal_ten():
    return literalvalues.LiteralValue(10, '10')
Пример #18
0
def literal_pi():
    return literalvalues.LiteralValue(3.14159, '3.14159')
Пример #19
0
def literal_three():
    return literalvalues.LiteralValue(3, '3')
Пример #20
0
def literal_two():
    return literalvalues.LiteralValue(2, '2')
Пример #21
0
def literal_one():
    return literalvalues.LiteralValue(1, '1')
Пример #22
0
def literal_minus_ten_point_fifty_one():
    return literalvalues.LiteralValue(-10.51, '-10.51')
Пример #23
0
def literal_dummy_timestamp(dummy_timestamp):
    return literalvalues.LiteralValue(dummy_timestamp, str(dummy_timestamp))
Пример #24
0
async def test_hmsinterval_limit(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second + 1, '')
    ]).eval()
    assert result == 1

    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second - 1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute, ''),
        literalvalues.LiteralValue(dummy_local_datetime.second, '')
    ]).eval()
    assert result == 1
Пример #25
0
async def test_mdinterval_months(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month - 1, ''),
        literalvalues.LiteralValue(1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month + 1, ''),
        literalvalues.LiteralValue(1, '')
    ]).eval()
    assert result == 1

    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month - 2, ''),
        literalvalues.LiteralValue(1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month - 1, ''),
        literalvalues.LiteralValue(1, '')
    ]).eval()
    assert result == 0

    result = await date.MDIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.month + 1, ''),
        literalvalues.LiteralValue(1, ''),
        literalvalues.LiteralValue(dummy_local_datetime.month + 2, ''),
        literalvalues.LiteralValue(1, '')
    ]).eval()
    assert result == 0
Пример #26
0
def literal_zero():
    return literalvalues.LiteralValue(0, '0')
Пример #27
0
async def test_hmsinterval_minutes(freezer, dummy_local_datetime):
    freezer.move_to(dummy_local_datetime)
    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute - 1, ''),
        literalvalues.LiteralValue(0, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute + 1, ''),
        literalvalues.LiteralValue(0, '')
    ]).eval(context={})
    assert result == 1

    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute - 2, ''),
        literalvalues.LiteralValue(0, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute - 1, ''),
        literalvalues.LiteralValue(0, '')
    ]).eval(context={})
    assert result == 0

    result = await date.HMSIntervalFunction([
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute + 1, ''),
        literalvalues.LiteralValue(0, ''),
        literalvalues.LiteralValue(dummy_local_datetime.hour, ''),
        literalvalues.LiteralValue(dummy_local_datetime.minute + 2, ''),
        literalvalues.LiteralValue(0, '')
    ]).eval(context={})
    assert result == 0
Пример #28
0
def literal_two_hundreds():
    return literalvalues.LiteralValue(200, '200')
Пример #29
0
def literal_one_hundred():
    return literalvalues.LiteralValue(100, '100')
Пример #30
0
def literal_false():
    return literalvalues.LiteralValue(False, 'false')