def test_mean_start_end_time(self): """ Test calculating mean values of start and end times of user according to the weekdays """ data = utils.get_data() mean_times = utils.get_mean_start_end_time(data[13]) self.assertIsInstance(mean_times, list) self.assertEqual(len(mean_times), 7) self.assertTupleEqual(mean_times[1], (33398.0, 54340.5))
def start_end_time_view(user_id): """ Returns time periods of given user spend in office. """ data = get_data() if user_id not in data: log.debug("User %s not found!", user_id) abort(404) mean_start_end_times = get_mean_start_end_time(data[user_id]) results = [ (weekday_abbr(weekday), mean_times[0], mean_times[1]) for weekday, mean_times in enumerate(mean_start_end_times) ] return results