Пример #1
0
def test_DateRange():

    startDate = Date(1, 1, 2010)

    #Default
    endDate = startDate.add_days(3)
    dtRange = date_range(startDate, endDate)
    assert dtRange[0] == Date(1, 1, 2010)
    assert dtRange[-1] == Date(4, 1, 2010)

    #1W Tenor
    endDate = startDate.add_days(20)
    tenor = "1W"
    dtRange = date_range(startDate, endDate, tenor)
    assert dtRange[0] == Date(1, 1, 2010)
    assert dtRange[-1] == Date(21, 1, 2010)

    #7D Tenor
    tenor = "7D"
    dtRange = date_range(startDate, endDate, tenor)
    assert dtRange[1] == Date(8, 1, 2010)
    assert dtRange[2] == Date(15, 1, 2010)

    #Same startDate
    assert date_range(startDate, startDate)[0] == Date(1, 1, 2010)

    #startDate before endDate"
    assert len(date_range(endDate, startDate)) == 0
Пример #2
0
def test_DateRange():

    start_date = Date(1, 1, 2010)

    testCases.header("Tenor", "Dates")

    end_date = start_date.add_days(3)
    tenor = "Default"
    testCases.print(tenor, date_range(start_date, end_date))

    end_date = start_date.add_days(20)
    tenor = "1W"
    testCases.print(tenor, date_range(start_date, end_date, tenor))

    tenor = "7D"
    testCases.print(tenor, date_range(start_date, end_date, tenor))

    testCases.header("Case", "Dates")

    case = "Same start_date"
    testCases.print(case, date_range(start_date, start_date))
    case = "start_date before end_date"
    testCases.print(case, date_range(end_date, start_date))