def test_get_monthly_worked_hours(self, years_dict): """ Test getting average working hours for each month. """ years_dict.return_value = {2013: {9: [30047, 23705, 24465]}} output = utils.get_monthly_worked_hours({}) self.assertListEqual(output[0], ['Year', '2013']) self.assertListEqual(output[9], ['Sep', 21])
def monthly_worked_hours_view(user_id): """ Returns monthly worked hours of given user """ data = get_data() if user_id not in data: log.debug("User %s not found!", user_id) abort(404) return get_monthly_worked_hours(data[user_id])