def test_push(self): name = "Dust" telephone = 123456 node = Node(name, telephone) my_queue = LinkedQueue() my_queue.push(node) self.assertEqual(my_queue.get_root(), node)
def test_pop_one(self): node = Node("James", 1234) my_queue = LinkedQueue() my_queue.push(node) pop_node = my_queue.pop() self.assertEqual(pop_node, node) self.assertEqual(my_queue.get_root(), None) self.assertEqual(my_queue.get_size(), 0)
def test_find_in_list(self): names = ("James", 1234), ("Kobe", 3456), ("Curry", 7890) nodes = [Node(name, telephone) for name, telephone in names] my_queue = LinkedQueue() for node in nodes: my_queue.push(node) marker = my_queue.get_root() for i in range(len(nodes) - 1, -1, -1): self.assertEqual(nodes[i], my_queue.find(marker.name)) marker = marker.get_next()
def test_pop(self): names = ("James", 1234), ("Kobe", 3456), ("Curry", 7890) nodes = [Node(name, telephone) for name, telephone in names] my_queue = LinkedQueue() for node in nodes: my_queue.push(node) pop_node = my_queue.pop() self.assertEqual(1, 1) self.assertEqual(pop_node, nodes[0]) self.assertEqual(my_queue.get_size(), len(nodes) - 1)
def test_push_many_to_queue(self): names = ("James", 1234), ("Kobe", 3456), ("Curry", 7890) nodes = [Node(name, telephone) for name, telephone in names] my_queue = LinkedQueue() for node in nodes: my_queue.push(node) self.assertEqual(my_queue.get_size(), len(nodes)) marker = my_queue.get_root() for i in range(len(nodes) - 1, -1, -1): self.assertEqual(nodes[i], marker) marker = marker.get_next()
from queue_list.linkedqueue import LinkedQueue from queue_list.node import Node from queue_list.my_queue import MyQueue # nba_menber = MyQueue() # # # # nba_menber.push(Node('Kobe', 123456)) # nba_menber.push(Node('James', 2568947)) # nba_menber.push(Node('Curry', 1984762)) # nba_menber.push(Node('Durant', 1862458)) # nba_menber.push(Node('Kwaii', 147635848)) # # node_ = nba_menber.pop() # node_.print_details() # print(nba_menber.get_size()) names = ("James", 1234), ("Kobe", 3456), ("Curry", 7890) nodes = [Node(name, telephone) for name, telephone in names] my_queue = LinkedQueue() for node in nodes: my_queue.push(node) print(my_queue.get_size()) pop_node = my_queue.pop() print(pop_node) print(my_queue.get_size())
def test_find_missing_in_list(self): my_queue = LinkedQueue() with self.assertRaises(LookupError): my_queue.find("Dust")
def test_pop_zero(self): my_queue = LinkedQueue() with self.assertRaises(BaseException): my_queue.pop()
def test_list_creation(self): my_queue = LinkedQueue() self.assertEqual(my_queue.get_size(), 0)