def presence_top_5_users_monthly_view(month):  # pylint: disable=invalid-name
    """
    Return 5 users from top of mean presence by month.
    """
    months = calendar.month_name[1:]
    if month not in months:
        abort(404)
    data_xml = get_data_xml()
    data = get_data()
    result = []
    for user_id in data_xml:
        result.append(
            {
                'avatar': data_xml[user_id]['avatar'],
                'user_id': user_id,
                'name': data_xml[user_id]['name'],
                'mean': mean_by_month(
                    data.get(user_id, [])
                    )[months.index(month)],
            }
        )
    return sorted(
        result,
        key=lambda sort_by: sort_by['mean'],
        reverse=True
    )[:5]
 def test_mean_by_month(self):
     """
     Test grouping mean time at work by month.
     """
     data = utils.get_data()
     sample_data_user = data[10]
     result = utils.mean_by_month(sample_data_user)
     self.assertListEqual(
         result,
         [
             0, 0, 0, 0,
             0, 0, 0, 0,
             26072.333333333332, 0, 0, 0
         ]
     )