Exemple #1
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)))))))))))
Exemple #3
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']
Exemple #4
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)
Exemple #5
0
def test_short_run_in_stack_returns_adjusted_distance():
    data = mock.mockdata['LONG_RUN'][0]
    stack = hdlr.DataValidHandler(
        hdlr.RunTypeHandler(
            hdlr.DateConverter(
                hdlr.TreadmillHandler(
                    hdlr.GarminDateHandler(
                        hdlr.ShortDistanceHandler(
                            hdlr.HouseMoveHandler(
                                hdlr.LockdownHandler(
                                    hdlr.LongRunHandler(
                                        hdlr.DefaultHandler(None))))))))))

    assert stack.handle(
        rundata=data)['distance'] == settings.LONG_RUN_DISTANCE
    assert 'original_distance' in stack.handle(rundata=data).keys()
    assert stack.handle(
        rundata=data)['original_distance'] == data['distance']
Exemple #6
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']
Exemple #7
0
def dateconverter():
    dateconverter = hdlr.DateConverter(successor=None)
    
    return dateconverter