def test_partial_update_queue(self):
     """test to see that handles the case where function only has time to update part of the updateQueue 
     before time to exit"""
     for ID in self.id_list[:200]:
         heapq.heappush(self.updateQueue, (0, ID))
         self.timeSeries[ID] = [{"utc": 0, "up": 0, "down": 0, "score": 0}]
     stopTime = time.time() + 5
     m_r.update_time_series(stopTime, self.updateFrequency, self.timeSeries, self.updateQueue)
     updated = False
     unupdated = False
     for key, val in self.timeSeries.items():
         if len(val) == 2:
             updated = True
         if len(val) == 1:
             unupdated = True
     self.assertTrue(updated)
     self.assertTrue(unupdated)
 def test_update_all_queue(self):
     """test to see that after updating all the posts that are in the queue
     it will wait until time for next update"""
     altered_list = self.id_list[:30]
     self.timeSeries = {}
     self.updateQueue = []
     for ID in altered_list:
         heapq.heappush(self.updateQueue, (0, ID))
         self.timeSeries[ID] = [{"utc": 0, "up": 0, "down": 0, "score": 0}]
     stopTime = time.time() + 10
     m_r.update_time_series(stopTime, self.updateFrequency, self.timeSeries, self.updateQueue)
     # check that all items are in timeSeries
     for ID in altered_list:
         self.assertTrue(ID in self.timeSeries.keys())
     testCount = 0
     for key, val in self.timeSeries.items():
         testCount += 1
         self.assertEqual(len(val), 2)  # assert there are two entries for each ID
 def test_empty_queue(self):
     """handles case in which the queue is empty"""
     self.updateQueue = []
     m_r.update_time_series(time.time() + 5, self.updateFrequency, self.timeSeries, self.updateQueue)
     self.assertEqual(len(self.updateQueue), 0)