switch parent_id and record_id in exception message according to the task instructions
This commit is contained in:
committed by
BethanyG
parent
6fee5dc9f5
commit
477be913de
@@ -18,7 +18,7 @@ def validate_record(record):
|
|||||||
raise ValueError('Only root should have equal record and parent id.')
|
raise ValueError('Only root should have equal record and parent id.')
|
||||||
|
|
||||||
if not record.equal_id() and record.parent_id >= record.record_id:
|
if not record.equal_id() and record.parent_id >= record.record_id:
|
||||||
raise ValueError("Node record_id should be smaller than it's parent_id.")
|
raise ValueError("Node parent_id should be smaller than it's record_id.")
|
||||||
|
|
||||||
|
|
||||||
def BuildTree(records):
|
def BuildTree(records):
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class TreeBuildingTest(unittest.TestCase):
|
|||||||
with self.assertRaises(ValueError) as err:
|
with self.assertRaises(ValueError) as err:
|
||||||
BuildTree(records)
|
BuildTree(records)
|
||||||
self.assertEqual(type(err.exception), ValueError)
|
self.assertEqual(type(err.exception), ValueError)
|
||||||
self.assertEqual(err.exception.args[0], "Node record_id should be smaller than it's parent_id.")
|
self.assertEqual(err.exception.args[0], "Node parent_id should be smaller than it's record_id.")
|
||||||
|
|
||||||
def test_no_root_node(self):
|
def test_no_root_node(self):
|
||||||
records = [
|
records = [
|
||||||
@@ -167,7 +167,7 @@ class TreeBuildingTest(unittest.TestCase):
|
|||||||
with self.assertRaises(ValueError) as err:
|
with self.assertRaises(ValueError) as err:
|
||||||
BuildTree(records)
|
BuildTree(records)
|
||||||
self.assertEqual(type(err.exception), ValueError)
|
self.assertEqual(type(err.exception), ValueError)
|
||||||
self.assertEqual(err.exception.args[0], "Node record_id should be smaller than it's parent_id.")
|
self.assertEqual(err.exception.args[0], "Node parent_id should be smaller than it's record_id.")
|
||||||
|
|
||||||
def test_higher_id_parent_of_lower_id(self):
|
def test_higher_id_parent_of_lower_id(self):
|
||||||
records = [
|
records = [
|
||||||
@@ -179,7 +179,7 @@ class TreeBuildingTest(unittest.TestCase):
|
|||||||
with self.assertRaises(ValueError) as err:
|
with self.assertRaises(ValueError) as err:
|
||||||
BuildTree(records)
|
BuildTree(records)
|
||||||
self.assertEqual(type(err.exception), ValueError)
|
self.assertEqual(type(err.exception), ValueError)
|
||||||
self.assertEqual(err.exception.args[0], "Node record_id should be smaller than it's parent_id.")
|
self.assertEqual(err.exception.args[0], "Node parent_id should be smaller than it's record_id.")
|
||||||
|
|
||||||
def assert_node_is_branch(self, node, node_id, children_count):
|
def assert_node_is_branch(self, node, node_id, children_count):
|
||||||
self.assertEqual(node.node_id, node_id)
|
self.assertEqual(node.node_id, node_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user