test: update tests to use instances
This commit is contained in:
@@ -9,7 +9,6 @@ These cover:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from aarecommon.errors.exception_handler import (
|
||||
AareAuthError,
|
||||
AareDBCommunicationError,
|
||||
@@ -57,48 +56,50 @@ from aarecommon.errors.exception_handler import (
|
||||
|
||||
|
||||
def test_aare_exception_class_critical_default_false():
|
||||
assert AareException.critical is False
|
||||
assert AareException().critical is False
|
||||
|
||||
|
||||
def test_phase3_classes_have_critical_default_true():
|
||||
for cls in (
|
||||
TellCommunicationError,
|
||||
TellConnectionException,
|
||||
CriticalTellException,
|
||||
SmargonCommunicationError,
|
||||
AerotechCommunicationError,
|
||||
JFJochCommunicationError,
|
||||
BECCommunicationError,
|
||||
StateTransitionFailed,
|
||||
MaintenanceStateException,
|
||||
BeamlineBusyException,
|
||||
BeamlineBusyTimeoutException,
|
||||
MagnetPositionSensorError,
|
||||
SmartMagnetFaultException,
|
||||
TransformationInvalidException,
|
||||
for e in (
|
||||
TellCommunicationError(),
|
||||
TellConnectionException(),
|
||||
CriticalTellException(),
|
||||
SmargonCommunicationError(),
|
||||
AerotechCommunicationError(),
|
||||
JFJochCommunicationError(),
|
||||
BECCommunicationError(),
|
||||
StateTransitionFailed(),
|
||||
MaintenanceStateException(),
|
||||
BeamlineBusyException(),
|
||||
BeamlineBusyTimeoutException(),
|
||||
MagnetPositionSensorError(),
|
||||
SmartMagnetFaultException(),
|
||||
TransformationInvalidException(),
|
||||
):
|
||||
assert cls.critical is True, f"{cls.__name__} should default to critical=True in Phase 3"
|
||||
assert e.critical is True, (
|
||||
f"{e.__class__.__name__} should default to critical=True in Phase 3"
|
||||
)
|
||||
|
||||
|
||||
def test_other_core_classes_keep_critical_default_false():
|
||||
for cls in (
|
||||
AutomationError,
|
||||
AareUserError,
|
||||
AareAuthError,
|
||||
TellException,
|
||||
SmargonException,
|
||||
AerotechException,
|
||||
JFJochException,
|
||||
BECException,
|
||||
BeamlineStateException,
|
||||
MountingFailed,
|
||||
UnmountingFailed,
|
||||
LoopCenteringFailed,
|
||||
TellCommandWhileBusyException,
|
||||
WarningTellException,
|
||||
AareDBCommunicationError,
|
||||
for e in (
|
||||
AutomationError(),
|
||||
AareUserError(),
|
||||
AareAuthError(),
|
||||
TellException(),
|
||||
SmargonException(),
|
||||
AerotechException(),
|
||||
JFJochException(),
|
||||
BECException(),
|
||||
BeamlineStateException(),
|
||||
MountingFailed(),
|
||||
UnmountingFailed(),
|
||||
LoopCenteringFailed(),
|
||||
TellCommandWhileBusyException(),
|
||||
WarningTellException(),
|
||||
AareDBCommunicationError(),
|
||||
):
|
||||
assert cls.critical is False, f"{cls.__name__} should remain critical=False"
|
||||
assert e.critical is False, f"{e.__class__.__name__} should remain critical=False"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -110,7 +111,7 @@ def test_instance_critical_override_true():
|
||||
exc = MountingFailed("mount fail", critical=True)
|
||||
assert exc.critical is True
|
||||
# class default unchanged
|
||||
assert MountingFailed.critical is False
|
||||
assert MountingFailed().critical is False
|
||||
|
||||
|
||||
def test_instance_critical_override_false():
|
||||
|
||||
Reference in New Issue
Block a user