refactor: use aarecommon and remove common
This commit is contained in:
1 parent
8f0a85316d
commit
13bddd43c7
172 files changed
+8267
-8214
No files matched your search
@@ -1,70 +1,112 @@
|
||||
from aare.common.error_codes import (
|
||||
AuthErrorCode,
|
||||
from aarecommon.errors.codes import (
|
||||
AareErrorCode,
|
||||
AuthErrorCode,
|
||||
code_for_exception_class,
|
||||
error_code_help,
|
||||
export_error_codes,
|
||||
export_error_codes_grouped,
|
||||
)
|
||||
|
||||
|
||||
def test_error_code_help_returns_string():
|
||||
help_text = error_code_help(AuthErrorCode.AUTHENTICATION_FAILED)
|
||||
assert isinstance(help_text, str)
|
||||
assert len(help_text) > 0
|
||||
|
||||
|
||||
def test_error_code_help_unknown_code():
|
||||
help_text = error_code_help("UNKNOWN_CODE")
|
||||
assert help_text is None
|
||||
|
||||
|
||||
def test_export_error_codes_contains_known_codes():
|
||||
exported = export_error_codes()
|
||||
assert AuthErrorCode.AUTHENTICATION_FAILED.name in exported
|
||||
|
||||
|
||||
def test_code_for_exception_class_basic():
|
||||
assert code_for_exception_class("TellCommunicationError") == "TELL_COMMUNICATION_ERROR"
|
||||
assert (
|
||||
code_for_exception_class("TellCommunicationError") == "TELL_COMMUNICATION_ERROR"
|
||||
)
|
||||
assert code_for_exception_class("MountingFailed") == "MOUNTING_FAILED"
|
||||
assert code_for_exception_class("LoopCenteringFailed") == "LOOP_CENTERING_FAILED"
|
||||
|
||||
|
||||
def test_code_for_exception_class_acronyms():
|
||||
assert code_for_exception_class("AXCFailed") == "AXC_FAILED"
|
||||
assert code_for_exception_class("AareDBCommunicationError") == "AARE_DB_COMMUNICATION_ERROR"
|
||||
assert code_for_exception_class("JFJochCommunicationError") == "JF_JOCH_COMMUNICATION_ERROR"
|
||||
assert (
|
||||
code_for_exception_class("AareDBCommunicationError")
|
||||
== "AARE_DB_COMMUNICATION_ERROR"
|
||||
)
|
||||
assert (
|
||||
code_for_exception_class("JFJochCommunicationError")
|
||||
== "JF_JOCH_COMMUNICATION_ERROR"
|
||||
)
|
||||
|
||||
|
||||
def test_code_for_each_concrete_exception_is_in_aare_error_code_enum():
|
||||
"""Every code we'd produce from the rebuilt hierarchy must exist in the
|
||||
AareErrorCode enum -- otherwise clients have no symbol to branch on."""
|
||||
from aare.common.exception_handler import (
|
||||
TellCommunicationError, TellConnectionException, CriticalTellException,
|
||||
WarningTellException, TellCommandWhileBusyException,
|
||||
MountingFailed, UnmountingFailed,
|
||||
SmargonCommunicationError, AerotechCommunicationError,
|
||||
JFJochCommunicationError, BECCommunicationError,
|
||||
AareDBCommunicationError, StateTransitionFailed,
|
||||
MaintenanceStateException, BeamlineBusyException,
|
||||
BeamlineBusyTimeoutException, DataCollectionException,
|
||||
RasterScanException, LoopCenteringFailed, AXCFailed,
|
||||
AutoRasterSampleSkipped, TransformationInvalidException,
|
||||
MagnetPositionSensorErorr, SmartMagnetFaultException,
|
||||
ManualMountException, SampleException, AuthenticationException,
|
||||
from aarecommon.errors.exception_handler import (
|
||||
AareDBCommunicationError,
|
||||
AerotechCommunicationError,
|
||||
AuthenticationException,
|
||||
AutoRasterSampleSkipped,
|
||||
AXCFailed,
|
||||
BeamlineBusyException,
|
||||
BeamlineBusyTimeoutException,
|
||||
BECCommunicationError,
|
||||
CriticalTellException,
|
||||
DataCollectionException,
|
||||
JFJochCommunicationError,
|
||||
LoopCenteringFailed,
|
||||
MagnetPositionSensorErorr,
|
||||
MaintenanceStateException,
|
||||
ManualMountException,
|
||||
MountingFailed,
|
||||
RasterScanException,
|
||||
SampleException,
|
||||
SmargonCommunicationError,
|
||||
SmartMagnetFaultException,
|
||||
StateTransitionFailed,
|
||||
TellCommandWhileBusyException,
|
||||
TellCommunicationError,
|
||||
TellConnectionException,
|
||||
TransformationInvalidException,
|
||||
UnmountingFailed,
|
||||
UserRightsException,
|
||||
WarningTellException,
|
||||
)
|
||||
|
||||
valid = {c.value for c in AareErrorCode}
|
||||
classes = [
|
||||
TellCommunicationError, TellConnectionException, CriticalTellException,
|
||||
WarningTellException, TellCommandWhileBusyException,
|
||||
MountingFailed, UnmountingFailed,
|
||||
SmargonCommunicationError, AerotechCommunicationError,
|
||||
JFJochCommunicationError, BECCommunicationError,
|
||||
AareDBCommunicationError, StateTransitionFailed,
|
||||
MaintenanceStateException, BeamlineBusyException,
|
||||
BeamlineBusyTimeoutException, DataCollectionException,
|
||||
RasterScanException, LoopCenteringFailed, AXCFailed,
|
||||
AutoRasterSampleSkipped, TransformationInvalidException,
|
||||
MagnetPositionSensorErorr, SmartMagnetFaultException,
|
||||
ManualMountException, SampleException, AuthenticationException,
|
||||
TellCommunicationError,
|
||||
TellConnectionException,
|
||||
CriticalTellException,
|
||||
WarningTellException,
|
||||
TellCommandWhileBusyException,
|
||||
MountingFailed,
|
||||
UnmountingFailed,
|
||||
SmargonCommunicationError,
|
||||
AerotechCommunicationError,
|
||||
JFJochCommunicationError,
|
||||
BECCommunicationError,
|
||||
AareDBCommunicationError,
|
||||
StateTransitionFailed,
|
||||
MaintenanceStateException,
|
||||
BeamlineBusyException,
|
||||
BeamlineBusyTimeoutException,
|
||||
DataCollectionException,
|
||||
RasterScanException,
|
||||
LoopCenteringFailed,
|
||||
AXCFailed,
|
||||
AutoRasterSampleSkipped,
|
||||
TransformationInvalidException,
|
||||
MagnetPositionSensorErorr,
|
||||
SmartMagnetFaultException,
|
||||
ManualMountException,
|
||||
SampleException,
|
||||
AuthenticationException,
|
||||
UserRightsException,
|
||||
]
|
||||
missing = []
|
||||
|
||||
Reference in new issue
Block a user