File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -75,14 +75,15 @@ def get_activity(self, activity_id):
7575 self .id ,
7676 activity_id )
7777
78- date_string = utils .match_filename_to_date_strings (
79- filename = activity_id ,
80- date_strings = self .metadata ['RIDES' ].keys ()
81- )
78+ metadata = None
8279 if self .metadata is not None :
83- metadata = self .metadata ['RIDES' ][date_string ]
84- else :
85- metadata = None
80+ date_string = utils .match_filename_to_date_strings (
81+ filename = activity_id ,
82+ date_strings = self .metadata ['RIDES' ].keys ()
83+ )
84+ if date_string is not None :
85+ metadata = self .metadata ['RIDES' ][date_string ]
86+
8687 return Activity (activity_id , data_filepath , metadata )
8788
8889 def activities_generator (self ):
Original file line number Diff line number Diff line change @@ -88,6 +88,12 @@ def test_get_activity(self, local_athlete):
8888 activity = local_athlete .get_activity ('1970_01_01_00_00_00.csv' )
8989 assert isinstance (activity , models .Activity )
9090
91+ def test_get_activity_missing_metadata (self , local_athlete ):
92+ local_athlete .metadata ['RIDES' ] = {}
93+ activity = local_athlete .get_activity ('1970_01_01_00_00_00.csv' )
94+ assert isinstance (activity , models .Activity )
95+ assert activity .metadata is None
96+
9197 def test_get_missing_activity (self , local_athlete ):
9298 activity = local_athlete .get_activity ('1900_01_01_00_00_00.csv' )
9399 assert not activity .has_data ()
You can’t perform that action at this time.
0 commit comments