def test_tictok_1(watopia_waistband): rfile = "test_data/tictoc/2020-10-29-19-10-19.fit" activity = Track(gpsbabel(str(rfile))) activity.distance() rs = TicTocResults(df=activity.df, segments=watopia_waistband) rs.calc_results() assert rs.results[1]['distance'] == 2358.3245572657142
def test_gpsbabel_stream(all_files): files = [x for x in all_files if x.suffix in ['.tcx', '.gpx', '.fit']] for f in files: with open(f, 'rb') as f: df = gpsbabel(f) assert {'Latitude', 'Longitude', 'Date_Time'}.intersection(set(df.columns)) == \ {'Latitude', 'Longitude', 'Date_Time'}, f"failing file: {str(f)}"
def test_rallystyle_basic(rally_files, roubaix): for f in rally_files: rs = RallyResults(df=Track(gpsbabel(str(f))).df, segments=roubaix) try: rs.match_checkpoints() except: print(f.name) raise rs.calc_results()
def test_roubaix_5(roubaix): rfile = "test_data/rallystyle/roubaix/richard_e.gpx" rs = RallyResults(df=Track(gpsbabel(str(rfile))).df, segments=roubaix) rs.match_checkpoints() rs.calc_results() assert rs.results[-1]['Segment_name'] == 'Finish' assert rs.results[-1]['location'] == {'lat': 40.116263, 'lon': -105.257817} assert rs.results[-1]['type'] == 'end' assert rs.results[-1]['duration'] == None assert rs.results[-1]['total_timed'].total_seconds() == timedelta( hours=1, minutes=8, seconds=57).total_seconds()
def test_tracks_1_gpsbabel(): activityfile = "../tests/test_data/tcx/test_tcx_1.tcx" df = gpsbabel(activityfile) t = Track(df=df) elev = t.elevation() assert elev['min_elevation'] == pytest.approx(1881.0, .1) assert elev['max_elevation'] == pytest.approx(2402.4, .1) assert elev['avg_elevation'] == pytest.approx(2147.082558643611, .1) assert elev['ascent'] == pytest.approx(1919.7999999999963, .1) assert elev['descent'] == pytest.approx(-1907.9999999999961, .1) dist = t.distance() assert dist['total_distance'] == pytest.approx(85485.77194022556, .1) ti = t.time() assert ti['elapsed_duration'] == timedelta(hours=5, minutes=46, seconds=0) assert ti['activity_time'] == timedelta(hours=5, minutes=46, seconds=0) assert ti['moving_time'] == timedelta(hours=5, minutes=27, seconds=10)
def test_roubaix_1(roubaix): rfile = "test_data/rallystyle/roubaix/dan_b.gpx" rs = RallyResults(df=Track(gpsbabel(str(rfile))).df, segments=roubaix) rs.match_checkpoints() rs.calc_results() assert rs.results[0]['duration'] == timedelta(hours=1, minutes=2, seconds=2) assert rs.results[0]['total_timed'] == timedelta(0) assert rs.results[1]['duration'] == timedelta(hours=0, minutes=0, seconds=33) assert rs.results[1]['total_timed'] == timedelta(0) assert rs.results[2]['duration'].total_seconds() == timedelta( hours=0, minutes=50, seconds=9).total_seconds() assert rs.results[2]['total_timed'].total_seconds() == timedelta( hours=0, minutes=50, seconds=9).total_seconds() assert rs.results[-1]['total_timed'].total_seconds() == timedelta( days=0, minutes=50, seconds=9).total_seconds() assert rs.results[-1]['duration'] == None
def test_roubaix_4(roubaix): rfile = "test_data/rallystyle/roubaix/michelle_m.gpx" rs = RallyResults(df=Track(gpsbabel(str(rfile))).df, segments=roubaix) rs.match_checkpoints() rs.calc_results()
def test_roubaix_2(roubaix): rfile = "test_data/rallystyle/roubaix/dean_d.fit" rs = RallyResults(df=Track(gpsbabel(str(rfile))).df, segments=roubaix) rs.match_checkpoints() rs.calc_results()
def test_gpsbabel_compressed(all_files): files = [x for x in all_files if x.suffix in ['.gz', '.zip']] for f in files: df = gpsbabel(str(f)) assert {'Latitude', 'Longitude', 'Date_Time'}.intersection(set(df.columns)) == \ {'Latitude', 'Longitude', 'Date_Time'}, f"failing file: {str(f)}"
def test_gpsbabel_basic(all_files): for f in all_files: if f.suffix in ['.tcx', '.gpx', '.fit']: df = gpsbabel(str(f)) assert {'Latitude', 'Longitude', 'Date_Time'}.intersection(set(df.columns)) == \ {'Latitude', 'Longitude', 'Date_Time'}, f"failing file: {str(f)}"