def test_delete_withExistingOperationInGivenTime_shouldDeleteOperationAndPropagateItsEffects(
            self):
        q = QueueFR()

        # q = [enqueue(1), dequeue(), ..., enqueue(t), dequeue()]
        # q will be an empty queue at the end of the loop
        for t in range(1, 20):
            q.enqueue(t, t)
            q.dequeue(t + 0.5)

        self.assertEqual(0, q.size())
        self.assertIsNone(q.back())
        self.assertIsNone(q.front())

        # Deleting all dequeue operations
        # q = [1, 2, ..., 19]
        for t in range(1, 20):
            q.delete(t + 0.5)
            self.assertEqual(t, q.size())
            self.assertEqual(19, q.back())
            self.assertEqual(20 - t, q.front())

        # Deleting all enqueue operations
        # q = []
        for t in range(1, 20):
            q.delete(t)
            self.assertEqual(19 - t, q.size())
            if t == 19:
                self.assertIsNone(q.back())
                self.assertIsNone(q.front())
            else:
                self.assertEqual(19, q.back())
                self.assertEqual(t + 1, q.front())
 def test_back_withUpdatesInCurrentTime_shouldReturnCurrentBackOfQueue(
         self):
     q = QueueFR()
     for i in range(1, 20):
         q.enqueue(i, i)
         self.assertEqual(i, q.back())
     for i in range(1, 20):
         q.dequeue(20 + i)
         if i == 19:
             self.assertIsNone(q.back())
         else:
             self.assertEqual(19, q.back())
    def test_enqueue_withDifferentTimes_shouldEnqueueValueAtGivenTime(self):
        q = QueueFR()

        # Should behave as ephemeral queue
        for t in range(20):
            q.enqueue(t, t)
            self.assertEqual(0, q.front())
            self.assertEqual(t, q.back())

        for t in range(1, 20):
            q.enqueue(t + 0.5, t + 0.5)
            self.assertEqual(0, q.front(t + 0.5))
            self.assertEqual(t + 0.5, q.back(t + 0.5))
    def test_back_withUpdatesInDifferentTimes_shouldReturnCorrectBackOfQueueAtGivenTime(
            self):
        q = QueueFR()

        for t in range(20):
            q.enqueue(t, t)

        for t in range(20):
            self.assertEqual(t, q.dequeue(t + 0.5))
            self.assertIsNone(q.back(t + 0.5))
 def test_constructor_shouldCreateEmptyQueue(self):
     q = QueueFR()
     self.assertEqual(0, q.size())
     self.assertIsNone(q.back())
     self.assertIsNone(q.front())
    def test_back_withEmptyQueueAtGivenTimes_shouldReturnNone(self):
        q = QueueFR()
        self.assertIsNone(q.back())

        for i in range(-20, 20):
            self.assertIsNone(q.back(i))