def test_peek_dequeue(): """ Este test prueba la creacion de una cola y que el orden de salida sea el correcto para la estructura en cuestion, y que el tamaño se reduzca para cada salida de objeto """ queue = q.newQueue(list_type) assert q.size(queue) == 0 assert q.isEmpty(queue) queue = q.newQueue(list_type) q.enqueue(queue, book5) q.enqueue(queue, book6) q.enqueue(queue, book3) q.enqueue(queue, book10) q.enqueue(queue, book1) q.enqueue(queue, book2) q.enqueue(queue, book8) q.enqueue(queue, book4) q.enqueue(queue, book7) q.enqueue(queue, book9) total = q.size(queue) while not (q.isEmpty(queue)): peek = q.peek(queue) assert (q.dequeue(queue) == peek) total -= 1 assert (total == q.size(queue))
def test_infoElements(self): """ """ self.queue = q.newQueue(self.list_type) self.assertEqual(q.size(self.queue), 0) self.assertTrue(q.isEmpty(self.queue)) q.enqueue(self.queue, self.movie5) q.enqueue(self.queue, self.movie6) q.enqueue(self.queue, self.movie3) q.enqueue(self.queue, self.movie10) q.enqueue(self.queue, self.movie1) q.enqueue(self.queue, self.movie2) q.enqueue(self.queue, self.movie8) q.enqueue(self.queue, self.movie4) q.enqueue(self.queue, self.movie7) q.enqueue(self.queue, self.movie9) elem = q.dequeue(self.queue) self.assertEqual(q.size(self.queue), 9) self.assertDictEqual(elem, self.movie5) elem = q.dequeue(self.queue) self.assertEqual(q.size(self.queue), 8) self.assertDictEqual(elem, self.movie6) elem = q.peek(self.queue) self.assertEqual(q.size(self.queue), 8) self.assertDictEqual(elem, self.movie3) q.enqueue(self.queue, self.movie5) self.assertEqual(q.size(self.queue), 9) elem = q.peek(self.queue) self.assertDictEqual(elem, self.movie3)
def test_infoElements (self): """ """ self.queue = q.newQueue(self.list_type) self.assertEqual (q.size(self.queue), 0) self.assertTrue (q.isEmpty(self.queue)) q.enqueue (self.queue, self.book5) q.enqueue (self.queue, self.book6) q.enqueue (self.queue, self.book3) q.enqueue (self.queue, self.book10) q.enqueue (self.queue, self.book1) q.enqueue (self.queue, self.book2) q.enqueue (self.queue, self.book8) q.enqueue (self.queue, self.book4) q.enqueue (self.queue, self.book7) q.enqueue (self.queue, self.book9) elem = q.dequeue (self.queue) self.assertEqual (q.size(self.queue), 9) self.assertDictEqual (elem, self.book5) elem = q.dequeue (self.queue) self.assertEqual (q.size(self.queue), 8) self.assertDictEqual (elem, self.book6) elem = q.peek (self.queue) self.assertEqual (q.size(self.queue), 8) self.assertDictEqual (elem, self.book3) q.enqueue (self.queue, self.book5) self.assertEqual (q.size(self.queue), 9) elem = q.peek (self.queue) self.assertDictEqual (elem, self.book3)
def test_emptyQueue(self): """ """ self.queue = q.newQueue(self.list_type) self.assertEqual(q.size(self.queue), 0) self.assertTrue(q.isEmpty(self.queue)) q.enqueue(self.queue, self.movie5) q.enqueue(self.queue, self.movie6) q.enqueue(self.queue, self.movie3) q.enqueue(self.queue, self.movie1) q.enqueue(self.queue, self.movie2) q.enqueue(self.queue, self.movie4) self.assertEqual(q.size(self.queue), 6)
def test_emptyQueue (self): """ """ self.queue = q.newQueue(self.list_type) self.assertEqual (q.size(self.queue), 0) self.assertTrue (q.isEmpty(self.queue)) q.enqueue (self.queue, self.book5) q.enqueue (self.queue, self.book6) q.enqueue (self.queue, self.book3) q.enqueue (self.queue, self.book10) q.enqueue (self.queue, self.book1) q.enqueue (self.queue, self.book2) q.enqueue (self.queue, self.book8) q.enqueue (self.queue, self.book4) q.enqueue (self.queue, self.book7) q.enqueue (self.queue, self.book9) self.assertEqual (q.size(self.queue), 10)
def test_error_dequeue(): """ Este test busca comprobar que es imposible eliminar un objeto de una cola vacia """ queue = q.newQueue(list_type) assert (q.size(queue) == 0) assert (q.isEmpty(queue)) with pytest.raises(Exception): q.dequeue(queue)
def test_sizeStack(): """ Se prueba la creacion de una cola y la relacion con el tamaño al ingresar datos """ queue = q.newQueue(list_type) assert (q.size(queue) == 0) assert (q.isEmpty(queue)) queue = q.newQueue(list_type) q.enqueue(queue, book5) q.enqueue(queue, book6) q.enqueue(queue, book3) q.enqueue(queue, book10) q.enqueue(queue, book1) q.enqueue(queue, book2) q.enqueue(queue, book8) q.enqueue(queue, book4) q.enqueue(queue, book7) q.enqueue(queue, book9) assert q.size(queue) == 10
def test_infoElements(): """ Este test busca confirmar que los datos se almacenen de forma correcta y que sean los valores correctos en el orden apropiado de la estructura. """ queue = q.newQueue(list_type) assert (q.size(queue) == 0) assert (q.isEmpty(queue)) queue = q.newQueue(list_type) q.enqueue(queue, book5) q.enqueue(queue, book6) q.enqueue(queue, book3) q.enqueue(queue, book10) q.enqueue(queue, book1) q.enqueue(queue, book2) q.enqueue(queue, book8) q.enqueue(queue, book4) q.enqueue(queue, book7) q.enqueue(queue, book9) elem = q.peek(queue) assert (q.size(queue) == 10) assert (elem == book5) elem = q.dequeue(queue) assert (q.size(queue) == 9) assert (elem == book5) elem = q.dequeue(queue) assert (q.size(queue) == 8) assert (elem == book6) elem = q.peek(queue) assert (q.size(queue) == 8) assert (elem == book3) q.enqueue(queue, book9) assert (q.size(queue) == 9) elem = q.peek(queue) assert (elem == book3)
def test_enqueue_dequeue(): """ Este test prueba que la cola pueda manejar inserciones y eliminaciones de forma correcta siguiendo un orden establecido, y que no quede referencia al objeto sacado despues de haberlo removido de la cola """ queue = q.newQueue(list_type) assert (q.size(queue) == 0) assert (q.isEmpty(queue)) q.enqueue(queue, book5) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book6) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book3) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book10) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book1) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book2) assert (q.size(queue) == 1) assert (q.peek(queue) == q.dequeue(queue)) assert (q.size(queue) == 0) q.enqueue(queue, book8) q.enqueue(queue, book4) q.enqueue(queue, book7) q.enqueue(queue, book9) assert (q.size(queue) == 4) assert book8 == q.dequeue(queue) assert book4 == q.dequeue(queue) assert book7 == q.dequeue(queue) assert book9 == q.dequeue(queue) assert (q.size(queue) == 0)