コード例 #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
ファイル: test_date.py プロジェクト: DigitEgal/qtoggleserver
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
ファイル: test_date.py プロジェクト: DigitEgal/qtoggleserver
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
ファイル: test_date.py プロジェクト: DigitEgal/qtoggleserver
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
ファイル: test_date.py プロジェクト: DigitEgal/qtoggleserver
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
ファイル: test_date.py プロジェクト: DigitEgal/qtoggleserver
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')