def test_update_from_backfill_with_previous_data(self):
     monthly_stats = MonthlyStats()
     # this is a collection resource
     monthly_stats.add(datetime(2018, 10, 1), u'resource1', 20)
     # this isn't a collection resource
     monthly_stats.add(datetime(2018, 10, 1), u'resource2', 15)
     # update from the backfill
     monthly_stats.update_from_backfill(
         u'10', u'2018', {
             u'collections': {
                 u'download_events': 3,
                 u'records': 10004,
             },
             u'research': {
                 u'download_events': 5829,
                 u'records': 32894932,
             }
         })
     assert monthly_stats.stats[u'10/2018'][u'collections'][
         u'download_events'] == 3 + 1
     assert monthly_stats.stats[u'10/2018'][u'collections'][
         u'records'] == 10004 + 20
     assert monthly_stats.stats[u'10/2018'][u'research'][
         u'download_events'] == 5829 + 1
     assert monthly_stats.stats[u'10/2018'][u'research'][
         u'records'] == 32894932 + 15
 def test_update_from_backfill_no_previous_data(self):
     monthly_stats = MonthlyStats()
     monthly_stats.update_from_backfill(
         u'10', u'2018', {
             u'collections': {
                 u'download_events': 102,
                 u'records': 1029
             },
             u'research': {
                 u'download_events': 4,
                 u'records': 902832
             }
         })
     assert monthly_stats.stats[u'10/2018'][u'collections'][
         u'download_events'] == 102
     assert monthly_stats.stats[u'10/2018'][u'collections'][
         u'records'] == 1029
     assert monthly_stats.stats[u'10/2018'][u'research'][
         u'download_events'] == 4
     assert monthly_stats.stats[u'10/2018'][u'research'][
         u'records'] == 902832
 def test_update_from_backfill_with_filters(self):
     monthly_stats = MonthlyStats(month=10, year=2018)
     monthly_stats.update_from_backfill(
         u'10', u'2018', {
             u'collections': {
                 u'download_events': 3,
                 u'records': 10004,
             },
             u'research': {
                 u'download_events': 5829,
                 u'records': 32894932,
             }
         })
     monthly_stats.update_from_backfill(
         u'11', u'2018', {
             u'collections': {
                 u'download_events': 3,
                 u'records': 10004,
             },
             u'research': {
                 u'download_events': 5829,
                 u'records': 32894932,
             }
         })
     monthly_stats.update_from_backfill(
         u'11', u'2017', {
             u'collections': {
                 u'download_events': 3,
                 u'records': 10004,
             },
             u'research': {
                 u'download_events': 5829,
                 u'records': 32894932,
             }
         })
     assert u'10/2018' in monthly_stats.stats
     assert u'11/2018' not in monthly_stats.stats
     assert u'11/2017' not in monthly_stats.stats