Skip to content

Commit

Permalink
Add a test for takeout activity data
Browse files Browse the repository at this point in the history
  • Loading branch information
rantahar committed Nov 30, 2023
1 parent da3e962 commit 928cabb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Binary file modified niimpy/sampledata/Takeout.zip
Binary file not shown.
31 changes: 31 additions & 0 deletions tests/reading/test_read_google_takeout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import pandas as pd
import numpy as np
import pytest
import datetime

import niimpy
from niimpy import config
Expand All @@ -19,3 +22,31 @@ def test_read_google_takeout_location():

assert data['activity_type'][1] == "STILL"
assert data['activity_inference_confidence'][1] == 62

def test_read_google_takeout_activity():
"""test reading activity data form a Google takeout file."""
data = niimpy.reading.google_takeout.activity(config.GOOGLE_TAKEOUT_PATH)

assert data.index[0] == pd.to_datetime("2023-11-20 00:00:00+0200")
assert np.isnan(data.iloc[4]["move_minutes_count"])
assert data.iloc[75]["move_minutes_count"] == 13.0
assert data.iloc[75]["calories_(kcal)"] == pytest.approx(43.42468)
assert data.iloc[75]["distance_(m)"] == pytest.approx(1174.961861)
assert data.iloc[75]["heart_points"] == 17.0
assert data.iloc[75]["heart_minutes"] == 11.0
assert np.isnan(data.iloc[75]["low_latitude_(deg)"])
assert np.isnan(data.iloc[75]["low_longitude_(deg)"])
assert np.isnan(data.iloc[75]["high_latitude_(deg)"])
assert np.isnan(data.iloc[75]["high_longitude_(deg)"])
assert data.iloc[75]["average_speed_(m/s)"] == pytest.approx(1.539091)
assert data.iloc[75]["max_speed_(m/s)"] == pytest.approx(2.123024)
assert data.iloc[75]["min_speed_(m/s)"] == pytest.approx(0.3197519)
assert data.iloc[75]["step_count"] == 1537.0
assert np.isnan(data.iloc[75]["average_weight_(kg)"])
assert np.isnan(data.iloc[75]["max_weight_(kg)"])
assert np.isnan(data.iloc[75]["min_weight_(kg)"])
assert pd.isnull(data.iloc[75]["road_biking_duration"])
assert data.iloc[75]["start_time"] == pd.to_datetime("2023-11-20 18:45:00+02:00")
assert data.iloc[75]["end_time"] == pd.to_datetime("2023-11-20 19:00:00+02:00")
assert data.iloc[75]["walking_duration"] == pd.to_timedelta("0 days 00:00:00.337365")

0 comments on commit 928cabb

Please sign in to comment.