def test_allocate_node(self):
     memory = Memory(4)
     node1 = memory.allocate_node()
     memory.set_node_label(node1, "A")
     node2 = memory.allocate_node()
     memory.set_node_label(node2, "B")
     self.assertEqual(memory.status(), [
         (None, "A", None, None),
         (None, "B", None, None),
         (None, None, 12, None),
         (None, None, None, None),
     ])
 def test_free_node(self):
     memory = Memory(4)
     node_a = memory.allocate_node()
     memory.set_node_label(node_a, "A")
     node_b = memory.allocate_node()
     memory.set_node_label(node_b, "B")
     memory.free_node(node_a)
     memory.set_node_label(memory.allocate_node(), "C")
     memory.set_node_label(memory.allocate_node(), "D")
     memory.free_node(node_b)
     memory.set_node_label(memory.allocate_node(), "E")
     self.assertEqual(memory.status(), [
         (None, "C", None, None),
         (None, "E", None, None),
         (None, "D", None, None),
         (None, None, None, None),
     ])
 def test_allocate_node_raising_error(self):
     memory = Memory(5)
     for _ in range(5):
         memory.allocate_node()
     self.assertRaises(NotEnoughMemoryNodesError, memory.allocate_node)