def test_remove_waiting_node_waiting_on_itself(self): node = DirectoryNode("path_part", None) node.lock() node.add_waiting_node(node) assert node in node.waiting_nodes assert node is node.waiting_for_node node.remove_waiting_node() assert node not in node.waiting_nodes assert node.waiting_for_node is None
def test_remove_waiting_node_waiting_on_another_node(self): node1 = DirectoryNode("path_part1", None) node2 = DirectoryNode("path_part2", node1) node2.lock(node1) node2.add_waiting_node(node2) assert node2 in node1.waiting_nodes assert node1 is node2.waiting_for_node node2.remove_waiting_node() assert node2 not in node1.waiting_nodes assert node2.waiting_for_node is None
def test_set_prior_waiting_on_itself(self): node = DirectoryNode("path_part", None) node.lock() node.waiting_nodes.append("another task") node.add_waiting_node(node) assert node in node.waiting_nodes assert node is node.waiting_nodes[1] assert node is node.waiting_for_node node.set_prior() assert node in node.waiting_nodes assert node is node.waiting_nodes[0] assert node is node.waiting_for_node
def test_set_prior_waiting_on_another_node(self): node1 = DirectoryNode("path_part1", None) node2 = DirectoryNode("path_part2", node1) node2.lock(node1) node1.waiting_nodes.append("another task") node2.add_waiting_node(node2) assert node2 in node1.waiting_nodes assert node2 is node1.waiting_nodes[1] assert node1 is node2.waiting_for_node node2.set_prior() assert node2 in node1.waiting_nodes assert node2 is node1.waiting_nodes[0] assert node1 is node2.waiting_for_node
def test_add_waiting_node_to_this_node_prior(self): node = DirectoryNode("path_part", None) node.lock() node2 = DirectoryNode("path_part2", node) node.add_waiting_node(node2) assert node2 in node.waiting_nodes node4 = DirectoryNode("path_part4", node) node.add_waiting_node(node4, prior_node=True) assert node4 in node.waiting_nodes assert node4 is node.waiting_nodes[0]
def test_add_waiting_node_to_this_node_not_prior(self): node = DirectoryNode("path_part", None) node.lock() node2 = DirectoryNode("path_part2", node) node.add_waiting_node(node2) assert node2 in node.waiting_nodes node3 = DirectoryNode("path_part3", node) node.add_waiting_node(node3, prior_node=False) assert node3 in node.waiting_nodes assert node3 is node.waiting_nodes[-1]
def test_add_waiting_node_to_another_node_prior(self): node = DirectoryNode("path_part", None) fake_node = FakeDirectoryNode() node.lock(fake_node) node2 = DirectoryNode("path_part2", node) node.add_waiting_node(node2) assert (node2, False,) in fake_node.waiting_nodes node3 = DirectoryNode("path_part3", node) node.add_waiting_node(node3, prior_node=True) assert (node3, True,) in fake_node.waiting_nodes assert (node3, True,) == fake_node.waiting_nodes[-1]