def test_transient_error(): error = Neo4jError("Oops", "Neo.TransientError.General.Error") assert isinstance(error, TransientError) assert error.code == "Neo.TransientError.General.Error" assert error.classification == "TransientError" assert error.category == "General" assert error.title == "Error" assert error.message == "Oops" assert str(error) == "[General.Error] Oops"
def test_unknown_error(): error = Neo4jError("Oops", "Neo.UnknownError.General.Error") assert isinstance(error, Neo4jError) assert error.code == "Neo.UnknownError.General.Error" assert error.classification == "UnknownError" assert error.category == "General" assert error.title == "Error" assert error.message == "Oops" assert str(error) == "[General.Error] Oops"
def test_database_error(): error = Neo4jError("Oops", "Neo.DatabaseError.General.Error") assert isinstance(error, DatabaseError) assert error.code == "Neo.DatabaseError.General.Error" assert error.classification == "DatabaseError" assert error.category == "General" assert error.title == "Error" assert error.message == "Oops" assert str(error) == "[General.Error] Oops"
def test_client_error_should_not_retry(): error = Neo4jError("Oops", "Neo.ClientError.General.Error") assert not error.should_retry()
def test_base_error_should_not_retry(): error = Neo4jError("Oops", "Neo.UnknownError.General.Error") assert not error.should_retry()
def test_bad_code_part_count(): with raises(ValueError): _ = Neo4jError("Oops", "Neo.ClientError.Error")
def test_bad_code_prefix(): with raises(ValueError): _ = Neo4jError("Oops", "Fake.ClientError.General.Error")
def test_bad_code_type(): with raises(ValueError): _ = Neo4jError("Oops", None)
def test_not_a_leader_error_should_invalidate_routing_table(): error = Neo4jError("Oops", "Neo.ClientError.Cluster.NotALeader") assert error.should_invalidate_routing_table()
def test_database_error_should_not_invalidate_routing_table(): error = Neo4jError("Oops", "Neo.DatabaseError.General.Error") assert not error.should_invalidate_routing_table()
def test_transient_error_should_not_invalidate_routing_table(): error = Neo4jError("Oops", "Neo.TransientError.General.Error") assert not error.should_invalidate_routing_table()
def test_transient_error_should_retry(): error = Neo4jError("Oops", "Neo.TransientError.General.Error") assert error.should_retry()
def test_database_error_should_not_retry(): error = Neo4jError("Oops", "Neo.DatabaseError.General.Error") assert not error.should_retry()
def test_not_a_leader_error_should_retry(): error = Neo4jError("Oops", "Neo.ClientError.Cluster.NotALeader") assert error.should_retry()
def test_lock_client_stopped_error_should_not_retry(): error = Neo4jError("Oops", "Neo.TransientError.Transaction.LockClientStopped") assert not error.should_retry()
def test_transaction_terminated_error_should_not_retry(): error = Neo4jError("Oops", "Neo.TransientError.Transaction.Terminated") assert not error.should_retry()