diff --git a/cognee/modules/graph/cognee_graph/CogneeGraphElements.py b/cognee/modules/graph/cognee_graph/CogneeGraphElements.py index c22cc5c18..2d8917d4a 100644 --- a/cognee/modules/graph/cognee_graph/CogneeGraphElements.py +++ b/cognee/modules/graph/cognee_graph/CogneeGraphElements.py @@ -106,7 +106,7 @@ class Edge: dimension: int = 1, ): if dimension <= 0: - InvalidDimensionsError() + raise InvalidDimensionsError() self.node1 = node1 self.node2 = node2 self.attributes = attributes if attributes is not None else {} diff --git a/cognee/tests/unit/modules/graph/cognee_graph_elements_test.py b/cognee/tests/unit/modules/graph/cognee_graph_elements_test.py index a852bcee3..a8fb17268 100644 --- a/cognee/tests/unit/modules/graph/cognee_graph_elements_test.py +++ b/cognee/tests/unit/modules/graph/cognee_graph_elements_test.py @@ -15,7 +15,7 @@ def test_node_initialization(): def test_node_invalid_dimension(): """Test that initializing a Node with a non-positive dimension raises an error.""" - with pytest.raises(InvalidDimensionsError, match="Dimensions must be a positive integers"): + with pytest.raises(InvalidDimensionsError): Node("node1", dimension=0) @@ -68,7 +68,7 @@ def test_is_node_alive_in_dimension(): def test_node_alive_invalid_dimension(): """Test that checking alive status with an invalid dimension raises an error.""" node = Node("node1", dimension=1) - with pytest.raises(DimensionOutOfRangeError, match="Dimension 1 is out of range"): + with pytest.raises(DimensionOutOfRangeError): node.is_node_alive_in_dimension(1) @@ -105,7 +105,7 @@ def test_edge_invalid_dimension(): """Test that initializing an Edge with a non-positive dimension raises an error.""" node1 = Node("node1") node2 = Node("node2") - with pytest.raises(DimensionOutOfRangeError, match="Dimensions must be a positive integer."): + with pytest.raises(InvalidDimensionsError): Edge(node1, node2, dimension=0) @@ -124,7 +124,7 @@ def test_edge_alive_invalid_dimension(): node1 = Node("node1") node2 = Node("node2") edge = Edge(node1, node2, dimension=1) - with pytest.raises(DimensionOutOfRangeError, match="Dimension 1 is out of range"): + with pytest.raises(DimensionOutOfRangeError): edge.is_edge_alive_in_dimension(1)