Exemple #1
0
 def _build_stats_entry_from_date_query(self, date_query):
     time_dict = build_time_dict(date_query)
     result = []
     for year in sorted(time_dict.keys()):
         for month in sorted(time_dict[year].keys()):
             result.append(('{} {}'.format(self._get_month_name(month), year), time_dict[year][month]))
     return result
def test_build_time_dict():
    test_input = [{
        '_id': {
            'month': 12,
            'year': 2016
        },
        'count': 10
    }, {
        '_id': {
            'month': 1,
            'year': 2017
        },
        'count': 8
    }]
    expected_result = {2016: {12: 10}, 2017: {1: 8}}
    assert build_time_dict(test_input) == expected_result
Exemple #3
0
 def test_build_time_dict(self):
     test_input = [{
         '_id': {
             'month': 12,
             'year': 2016
         },
         'count': 10
     }, {
         '_id': {
             'month': 1,
             'year': 2017
         },
         'count': 8
     }]
     expected_result = {2016: {12: 10}, 2017: {1: 8}}
     self.assertEqual(build_time_dict(test_input), expected_result)