コード例 #1
0
def test_parse_parameter_end_current_year_ymd():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-12-31" == parse_parameter("END_CURRENT_YEAR", current_date)
    assert "2020-12-31" == parse_parameter("END_CURRENT_YEAR+1", current_date)
    assert "2018-12-31 00:00:00" == parse_parameter(
        "END_CURRENT_YEAR-1 | %Y-%m-%d 00:00:00", current_date)
    assert "2018-12-31 23:59:59" == parse_parameter(
        "END_CURRENT_YEAR - 1 | %Y-%m-%d 23:59:59", current_date)
コード例 #2
0
def test_parse_parameter_end_current_month_ymd():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-12-31" == parse_parameter("END_CURRENT_MONTH", current_date)
    assert "2020-01-31" == parse_parameter("END_CURRENT_MONTH+1", current_date)
    assert "2019-11-30 00:00:00" == parse_parameter(
        "END_CURRENT_MONTH-1 | %Y-%m-%d 00:00:00", current_date)
    assert "2019-11-30 23:59:59" == parse_parameter(
        "END_CURRENT_MONTH - 1 | %Y-%m-%d 23:59:59", current_date)
コード例 #3
0
def test_parse_parameter_start_current_month_year():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-01-01" == parse_parameter("START_CURRENT_YEAR", current_date)
    assert "2020-01-01" == parse_parameter("START_CURRENT_YEAR+1",
                                           current_date)
    assert "2020-01-01 00:00:00" == parse_parameter(
        "START_CURRENT_YEAR+1|%Y-%m-%d 00:00:00", current_date)
    assert "2020-01-01 23:59:59" == parse_parameter(
        "START_CURRENT_YEAR + 1 | %Y-%m-%d 23:59:59", current_date)
コード例 #4
0
def test_parse_parameter_current_date_ymd_seperator_slash():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-12-30" == parse_parameter("CURRENT_DATE,%Y-%m-%d",
                                           current_date,
                                           format_separator=",")
    assert "2019-12-30" == parse_parameter("CURRENT_DATE:%Y-%m-%d",
                                           current_date,
                                           format_separator=":")
    assert "2019-12-30" == parse_parameter("CURRENT_DATE#%Y-%m-%d",
                                           current_date,
                                           format_separator="#")
コード例 #5
0
def test_parse_parameter_current_date_ymd():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-12-30" == parse_parameter("CURRENT_DATE", current_date)
    assert "2019-12-31" == parse_formula("CURRENT_DATE+1", current_date)
    assert "2019-12-31 00:00:00" == parse_formula(
        "CURRENT_DATE + 1", current_date, date_format="%Y-%m-%d 00:00:00")
    assert "2019-12-31 23:59:59" == parse_formula(
        "CURRENT_DATE + 1", current_date, date_format="%Y-%m-%d 23:59:59")
コード例 #6
0
def test_parse_parameter():
    current_date = datetime.datetime.strptime("2019-12-30", "%Y-%m-%d").date()

    assert "2019-12-30" == parse_parameter("2019-12-30", current_date)
    assert "2019-12-31" == parse_formula("2019-12-31", current_date)
    assert "2019-12-31 00:00:00" == parse_formula(
        "2019-12-31 00:00:00", current_date, date_format="%Y-%m-%d 00:00:00")
    assert "2019-12-31 23:59:59" == parse_formula(
        "2019-12-31 23:59:59", current_date, date_format="%Y-%m-%d 23:59:59")

    assert "field1" == parse_parameter("field1", current_date)
    assert "55" == parse_parameter("55", current_date)
    assert "55.2" == parse_parameter("55.2", current_date)
    assert "" == parse_parameter("", current_date)
    assert parse_parameter(False, current_date) is False