예제 #1
0
def test_timespan_args_begin_date_only_str_and_thru_str():
    """Tests timespan arguments: begin_str date only, thru_str.
    """
    start, _ = timespan(begin_str=REF_BEGIN_DATE_ONLY_STR)

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_DATETIME_STR
예제 #2
0
def test_timespan_args_begin_str_and_thru_date_only_str():
    """Tests timespan arguments: begin_str date only, thru_str.
    """
    _, end = timespan(begin_str=REF_BEGIN_STR, thru_str=REF_THRU_DATE_ONLY_STR)

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_DATETIME_STR
예제 #3
0
def test_timespan_args_week_str():
    """Tests timespan argument: week_str.
    """
    start, end = timespan(week_str=REF_WEEK_STR)

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_STR

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_STR
예제 #4
0
def test_timespan_args_begin_str_and_thru_str():
    """Tests timespan arguments: begin_str, thru_str.
    """
    start, end = timespan(begin_str=REF_BEGIN_STR, thru_str=REF_THRU_STR)

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_STR

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_STR
예제 #5
0
def test_timespan_args_begin_str_missing_and_thru_str():
    """Tests timespan arguments, begin_str missing, thru_str.
    """
    start, end = timespan(thru_str=REF_THRU_STR)
    start_first = datetime(2000, 1, 1, 0, 0).astimezone()

    assert isinstance(start, datetime)
    assert start.isoformat() == start_first.isoformat()

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_STR
예제 #6
0
def test_timespan_args_begin_str_and_thru_str_missing():
    """Tests timespan arguments: begin_str, thru_str missing.
    """
    start, end = timespan(begin_str=REF_BEGIN_STR)
    end_now = datetime.now(tz.tzlocal())

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_STR

    assert isinstance(end, datetime)
    assert end.isoformat()[0:18] == end_now.isoformat()[0:18]
예제 #7
0
def test_timespan_args_week_str_and_thru_str():
    """Tests timespan arguments: week_str, thru_str.
    """
    start, end = timespan(week_str=REF_BEGIN_ISO, thru_str=REF_THRU_STR)
    begin = datetime.fromisocalendar(2020, 10, 1).astimezone()

    assert isinstance(start, datetime)
    assert start.isoformat() == begin.isoformat()

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_STR
예제 #8
0
def test_timespan_args_begin_and_thru_none():
    """Tests timespan arguments: begin, thru=None.
    """
    begin = datetime.fromisoformat(REF_BEGIN_STR)
    start, end = timespan(begin=begin, thru=None)
    thru_now = datetime.now(tz.tzlocal())

    assert isinstance(start, datetime)
    assert start == begin

    assert isinstance(end, datetime)
    assert end.isoformat()[0:18] == thru_now.isoformat()[0:18]
예제 #9
0
def test_timespan_args_begin_and_thru():
    """Tests timespan arguments: begin, thru.
    """
    begin = datetime.fromisoformat(REF_BEGIN_STR)
    thru = datetime.fromisoformat(REF_THRU_STR)
    start, end = timespan(begin=begin, thru=thru)

    assert isinstance(start, datetime)
    assert start == begin

    assert isinstance(end, datetime)
    assert end == thru
예제 #10
0
def test_timespan_args_week_str_and_begin_str():
    """Tests timespan arguments: week_str, begin_str.
    """
    start, end = timespan(week_str=REF_THRU_ISO, begin_str=REF_BEGIN_STR)
    thru = datetime.fromisocalendar(2020, 25,
                                    1).astimezone() + timedelta(days=7)

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_STR

    assert isinstance(end, datetime)
    assert end.isoformat() == thru.isoformat()
예제 #11
0
def test_timespan_args_begin_iso_week_and_thru_str_missing():
    """Tests timespan arguments: begin iso week, thru_str missing.
    """
    start, end = timespan(begin_str=REF_BEGIN_ISO)
    begin = datetime.fromisocalendar(2020, 10, 1).astimezone()
    end_now = datetime.now(tz.tzlocal())

    assert isinstance(start, datetime)
    assert start == begin

    assert isinstance(end, datetime)
    assert end.isoformat()[0:18] == end_now.isoformat()[0:18]
예제 #12
0
def test_timespan_args_begin_missing_and_thru():
    """Tests timespan arguments: begin missing, thru.
    """
    thru = datetime.fromisoformat(REF_THRU_STR)
    start, end = timespan(thru=thru)
    start_first = datetime(2000, 1, 1, 0, 0).astimezone()

    assert isinstance(start, datetime)
    assert start == start_first

    assert isinstance(end, datetime)
    assert end == thru
예제 #13
0
def test_timespan_args_begin_str_missing_and_thru_iso_week():
    """Tests timespan arguments: begin_str missing, thru iso week.
    """
    start, end = timespan(thru_str=REF_THRU_ISO)
    start_first = datetime(2000, 1, 1, 0, 0).astimezone()
    thru = datetime.fromisocalendar(2020, 25,
                                    1).astimezone() + timedelta(days=7)

    assert isinstance(start, datetime)
    assert start.isoformat() == start_first.isoformat()

    assert isinstance(end, datetime)
    assert end == thru
예제 #14
0
def test_timespan_args_begin_iso_week_and_thru_iso_week():
    """Tests timespan arguments: begin iso week, thru iso week.
    """
    start, end = timespan(begin_str=REF_BEGIN_ISO, thru_str=REF_THRU_ISO)
    begin = datetime.fromisocalendar(2020, 10, 1).astimezone()
    thru = datetime.fromisocalendar(2020, 25,
                                    1).astimezone() + timedelta(days=7)

    assert isinstance(start, datetime)
    assert start == begin

    assert isinstance(end, datetime)
    assert end == thru
예제 #15
0
def test_timespan_args_week_str_and_begin_str_and_thru_str():
    """Tests timespan arguments: week_str, begin_str, thru_str.

    The week string is ignored in this case.
    """
    start, end = timespan(week_str=REF_WEEK_STR,
                          begin_str=REF_BEGIN_STR,
                          thru_str=REF_THRU_STR)

    assert isinstance(start, datetime)
    assert start.isoformat() == REF_BEGIN_STR

    assert isinstance(end, datetime)
    assert end.isoformat() == REF_THRU_STR