def test_compute_moving_averages_computes_moving_averages(self):
     """Should compute moving averages for given feature and window"""
     self.assertEqual([1, 1.5, 3],
                      list(compute_moving_averages(self.test_activities,
                                                   feature_name='test_var',
                                                   window_days=2).test_var_2))
 def test_compute_moving_averages_no_new_column_for_existing_moving_averages(self):
     """Should not add new column if one or more moving averages were computed for the given feature"""
     self.assertEqual(len(test_activities.columns),
                      len(compute_moving_averages(
                              self.test_activities, feature_name='average_speed', window_days=28).columns))
 def test_compute_moving_averages_adds_column_for_given_feature(self):
     """Should create new column with name [original_feature_name]_[window_size] as name"""
     self.assertIn('test_var_3',
                   compute_moving_averages(self.test_activities, feature_name='test_var', window_days=3).columns)
 def test_compute_moving_averages_retains_original_data(self):
     """Should compute moving average for given feature retaining existing features and observations"""
     self.assertEqual(3, len(compute_moving_averages(self.test_activities, feature_name='test_var', window_days=2)))
     self.assertEqual(len(test_activities.columns) + 1,
                      len(compute_moving_averages(
                              self.test_activities, feature_name='test_var', window_days=2).columns))