def test_mean_start_stop_incorrect_input(self): """ Test counting starts and ends by weekday. Incorrect input type. """ with self.assertRaises(TypeError): utils.mean_start_stop({'first': 123, 'second': '123'})
def test_mean_start_stop_list(self): """ Test counting starts and ends by weekday. Checks if the result is a list. """ data = utils.get_data() counted_by_weekday = utils.mean_start_stop(data[10]) self.assertIsInstance(counted_by_weekday, list)
def presence_start_end(user_id): """ Return presence mean start and end times for given user grouped by weekday. """ data = utils.get_data() if user_id not in data: log.debug('User %s not found!', user_id) abort(404) weekdays = utils.mean_start_stop(data[user_id]) result = [ (calendar.day_abbr[weekday], day['Start'], day['End']) for weekday, day in enumerate(weekdays) ] return result