def test_high_3():
    """
    Tests overkill values that exceed brevet distance by only one
    """
    # Both should be identical to high_1 results
    assert a_same(open_time(201, 200, d_arrow), arrow.get('2000-01-01 05:53:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(open_time(401, 400, d_arrow), arrow.get('2000-01-01 12:08:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(1001, 1000, d_arrow), arrow.get('2000-01-04 03:00:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(601, 600, d_arrow), arrow.get('2000-01-02 16:00:00', 'YYYY-MM-DD HH:mm:ss'))
def test_high_1():
    """
    Tests non-overkill values (where control distance = brevet distance)
    """
    # Should have no effect on either set
    assert a_same(open_time(200, 200, d_arrow), arrow.get('2000-01-01 05:53:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(open_time(400, 400, d_arrow), arrow.get('2000-01-01 12:08:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(1000, 1000, d_arrow), arrow.get('2000-01-04 03:00:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(600, 600, d_arrow), arrow.get('2000-01-02 16:00:00', 'YYYY-MM-DD HH:mm:ss'))
def test_high_2():
    """
    Tests overkill values (control values that exceed
    the brevet distance by 20% or less)
    """
    # Both should be identical to high_1 results
    assert a_same(open_time(240, 200, d_arrow), arrow.get('2000-01-01 05:53:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(open_time(480, 400, d_arrow), arrow.get('2000-01-01 12:08:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(1200, 1000, d_arrow), arrow.get('2000-01-04 03:00:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(720, 600, d_arrow), arrow.get('2000-01-02 16:00:00', 'YYYY-MM-DD HH:mm:ss'))
예제 #4
0
def longer_distance_open():
    """
    Testing open times at distances farther than 200km, taken from the algorithm description webpage
    """
    assert acp_times.open_time(350, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=10,
                                                                                                             minutes=34)
    assert acp_times.open_time(550, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=17,
                                                                                                             minutes=8)
    assert acp_times.open_time(890, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=29,
                                                                                                             minutes=9)
def test_random():
    """
    Tests a small variety of non-special values
    """
    # open_time
    assert a_same(open_time(144, 200, d_arrow), arrow.get('2000-01-01 04:14:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(open_time(453, 600, d_arrow), arrow.get('2000-01-01 13:54:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(open_time(200, 400, d_arrow), arrow.get('2000-01-01 05:53:00', 'YYYY-MM-DD HH:mm:ss'))
    # close_time
    assert a_same(close_time(888, 1000, d_arrow), arrow.get('2000-01-03 17:12:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(81, 300, d_arrow), arrow.get('2000-01-01 05:24:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(347, 600, d_arrow), arrow.get('2000-01-01 23:08:00', 'YYYY-MM-DD HH:mm:ss'))
예제 #6
0
def basic_test_open():
    """
    Example open times from the algorithm description webpage
    """
    assert acp_times.open_time(60, 200, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=1,
                                                                                                           minutes=46)
    assert acp_times.open_time(120, 200, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=3,
                                                                                                            minutes=32)
    assert acp_times.open_time(175, 200, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=5,
                                                                                                            minutes=9)
    assert acp_times.open_time(200, 200, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=5,
                                                                                                            minutes=53)
예제 #7
0
def test_open_under_60():
    assert str(acp_times.open_time(
        0, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T00:00:00+00:00"
    assert str(acp_times.open_time(
        10, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T00:18:00+00:00"
    assert str(acp_times.open_time(
        34, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T01:00:00+00:00"
    assert str(acp_times.open_time(
        59, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T01:44:00+00:00"
예제 #8
0
def test_open_600():
    assert str(acp_times.open_time(
        400, 600,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T12:08:00+00:00"
    assert str(acp_times.open_time(
        401, 600,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T12:10:00+00:00"
    assert str(acp_times.open_time(
        599, 600,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T18:46:00+00:00"
    assert str(acp_times.open_time(
        600, 600,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T18:48:00+00:00"
    assert str(acp_times.open_time(
        601, 600,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T18:48:00+00:00"
예제 #9
0
def test_controle_close_to_start():
    """
    Tests open/close times for controle locations for 60 km and under
	"""
    assert acp_times.open_time(0, 1000, sample_time).replace(second=0, microsecond=0) == sample_time
    assert acp_times.close_time(0, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=1)

    assert acp_times.open_time(5, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(minutes=9)
    assert acp_times.close_time(5, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=1,
                                                                                                            minutes=15)

    assert acp_times.open_time(20, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(minutes=35)
    assert acp_times.close_time(20, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=2)

    assert acp_times.open_time(30, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(minutes=53)
    assert acp_times.close_time(30, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=2,
                                                                                                             minutes=30)

    assert acp_times.open_time(60, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=1,
                                                                                                            minutes=46)
    assert acp_times.close_time(60, 1000, sample_time).replace(second=0, microsecond=0) == sample_time.shift(hours=4)
def test_low_2():
    """
    Tests <= 60km values (special cases) for
    control distances in both. Should create
    special exceptions for close_time and
    not do so for open_time
    """
    # open_time should calculate as normal
    assert a_same(open_time(50, 400, d_arrow), arrow.get('2000-01-01 01:28:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(20, 300, d_arrow), arrow.get('2000-01-01 02:00:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(40, 400, d_arrow), arrow.get('2000-01-01 03:00:00', 'YYYY-MM-DD HH:mm:ss'))
    assert a_same(close_time(60, 600, d_arrow), arrow.get('2000-01-01 04:00:00', 'YYYY-MM-DD HH:mm:ss'))
    # Should use updated formula past 61
    assert a_same(close_time(61, 1000, d_arrow), arrow.get('2000-01-01 04:04:00', 'YYYY-MM-DD HH:mm:ss'))
예제 #11
0
def test_open_300():
    assert str(acp_times.open_time(
        200, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T05:53:00+00:00"
    assert str(acp_times.open_time(
        201, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T05:55:00+00:00"
    assert str(acp_times.open_time(
        250, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T07:27:00+00:00"
    assert str(acp_times.open_time(
        299, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T08:59:00+00:00"
    assert str(acp_times.open_time(
        300, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T09:00:00+00:00"
    assert str(acp_times.open_time(
        301, 300,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T09:00:00+00:00"
예제 #12
0
def test_open_over_60():
    assert str(acp_times.open_time(
        60, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T01:46:00+00:00"
    assert str(acp_times.open_time(
        61, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T01:48:00+00:00"
    assert str(acp_times.open_time(
        100, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T02:56:00+00:00"
    assert str(acp_times.open_time(
        199, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T05:51:00+00:00"
    assert str(acp_times.open_time(
        200, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T05:53:00+00:00"
    assert str(acp_times.open_time(
        206, 200,
        arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T05:53:00+00:00"
def test_low_1():
    """
    Tests 0km control distances
    """
    assert a_same(open_time(0, 200, d_arrow), d_arrow)
    assert a_same(close_time(0, 200, d_arrow), arrow.get('2000-01-01 01:00:00', 'YYYY-MM-DD HH:mm:ss'))
예제 #14
0
def test_open_400():
    assert str(acp_times.open_time(300, 400, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T09:00:00+00:00"
    assert str(acp_times.open_time(301, 400, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T09:02:00+00:00"
    assert str(acp_times.open_time(399, 400, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T12:06:00+00:00"
    assert str(acp_times.open_time(400, 400, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T12:08:00+00:00"
    assert str(acp_times.open_time(401, 400, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T12:08:00+00:00"
예제 #15
0
def test_open_1000():
    assert str(acp_times.open_time(600, 1000, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T18:48:00+00:00"
    assert str(acp_times.open_time(601, 1000, arrow.get('2020-01-01T00:00:00'))) == "2020-01-01T18:50:00+00:00"
    assert str(acp_times.open_time(999, 1000, arrow.get('2020-01-01T00:00:00'))) == "2020-01-02T09:03:00+00:00"
    assert str(acp_times.open_time(1000, 1000, arrow.get('2020-01-01T00:00:00'))) == "2020-01-02T09:05:00+00:00"
    assert str(acp_times.open_time(1001, 1000, arrow.get('2020-01-01T00:00:00'))) == "2020-01-02T09:05:00+00:00"