示例#1
0
def test_long_run_in_stack_returns_rundata():
    data = mock.mockdata['VALID_RUN'][0]
    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.TreadmillHandler(
                hdlr.GarminDateHandler(
                    hdlr.ShortDistanceHandler(
                        hdlr.DefaultHandler(None))))))

    assert stack.handle(rundata=data) 
示例#2
0
def test_post_garmin_runs_through_chain_of_command():
    data = mock.mockdata['POST_GARMIN_RUN'][0]

    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.DateConverter(
                hdlr.TreadmillHandler(
                    hdlr.GarminDateHandler(
                        hdlr.DefaultHandler(None))))))

    assert stack.handle(rundata=data) == data
 def __init__(self):
     self.handler = hdlr.DataValidHandler(
         hdlr.RunTypeHandler(
             hdlr.DateConverter(
                 hdlr.TreadmillHandler(
                     hdlr.GarminDateHandler(
                         hdlr.ShortDistanceHandler(
                             hdlr.HouseMoveHandler(
                                 hdlr.FiveKMDateHandler(
                                     hdlr.LockdownHandler(
                                         hdlr.LongRunHandler(
                                             hdlr.DefaultHandler(
                                                 None)))))))))))
示例#4
0
def test_pvalid_run_in_stack_returns_adjusted_distance():
    data = mock.mockdata['VALID_RUN'][0]
    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.TreadmillHandler(
                hdlr.GarminDateHandler(
                    hdlr.ShortDistanceHandler(
                        hdlr.HouseMoveHandler(
                            hdlr.LockdownHandler(
                                hdlr.LongRunHandler(
                                    hdlr.DefaultHandler(None)))))))))

    assert stack.handle(
        rundata=data)['distance'] == settings.SHORT_RUN_DISTANCE
    assert 'original_distance' in stack.handle(rundata=data).keys()
    assert stack.handle(
        rundata=data)['original_distance'] == data['distance']
示例#5
0
def test_pre_five_km_run_in_stack_returns_rundata():
    data = mock.mockdata['PRE_FIVEKM_RUN'][0]
    runmonth, runday, runyear = data['date'].split('/')
    run_date = datetime.datetime(int(runyear), int(runmonth), int(runday))
    data['adjusted_date'] = run_date

    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.DateConverter(
                hdlr.TreadmillHandler(
                    hdlr.GarminDateHandler(
                        hdlr.ShortDistanceHandler(
                            hdlr.HouseMoveHandler(
                                hdlr.FiveKMDateHandler(
                                    hdlr.DefaultHandler(None)))))))))

    assert stack.handle(rundata=data)['distance'] == data['distance']
示例#6
0
def test_dateconverter_adds_adjusted_date_key(dateconverter):
    data = mock.mockdata['VALID_RUN'][0]

    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.DateConverter(
                hdlr.TreadmillHandler(
                    hdlr.GarminDateHandler(
                        hdlr.ShortDistanceHandler(
                            hdlr.HouseMoveHandler(
                                hdlr.LockdownHandler(
                                    hdlr.LongRunHandler(
                                        hdlr.DefaultHandler(None))))))))))

    processed_data = stack.handle(rundata=data)
    assert 'adjusted_date' in processed_data.keys()
    assert processed_data['adjusted_date'] == datetime.datetime(2020, 2, 18, 0, 0)
示例#7
0
def test_pre_move_run_in_stack_returns_adjusted_distance():
    data = mock.mockdata['PRE_MOVE_RUN'][0]
    runmonth, runday, runyear = data['date'].split('/')
    run_date = datetime.datetime(int(runyear), int(runmonth), int(runday))
    data['adjusted_date'] = run_date
    
    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.DateConverter(
                hdlr.TreadmillHandler(
                    hdlr.GarminDateHandler(
                        hdlr.ShortDistanceHandler(
                            hdlr.HouseMoveHandler(
                                hdlr.DefaultHandler(None))))))))

    assert stack.handle(
        rundata=data)['distance'] == settings.HOUSEMOVE_DISTANCE
    assert 'original_distance' in stack.handle(rundata=data).keys()
    assert stack.handle(
        rundata=data)['original_distance'] == data['distance']
示例#8
0
def test_garmindatehandler_needs_successor():
    with pytest.raises(TypeError):
        garminhandler = hdlr.GarminDateHandler()
示例#9
0
def garminhandler():
    garminhandler = hdlr.GarminDateHandler(successor=None)
    
    return garminhandler