31 lines
1.9 KiB
Python
31 lines
1.9 KiB
Python
import pytest
|
|
|
|
def test_check_if_participant_id_is_valid_standalone__different_assignments():
|
|
from BreCal.validators.input_validation_utils import check_if_participant_id_is_valid_standalone
|
|
from BreCal.schemas.model import ParticipantType
|
|
# participant id 10 has the ParticipantType 10. This means, the participant is, both, agency and terminal.
|
|
# upon assignment, the participant can take the role of terminal, agency or theoretically, both.
|
|
|
|
participant_id = 10
|
|
participant_type = ParticipantType(10)
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=participant_type)
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(2))
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(8))
|
|
|
|
# failure cases: BSMD, PILOT, MOORING, PORT_ADMINISTRATION, TUG
|
|
with pytest.raises(AssertionError, match="wrong role assignment."):
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(1)), f"wrong role assignment."
|
|
|
|
with pytest.raises(AssertionError, match="wrong role assignment."):
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(4)), f"wrong role assignment."
|
|
|
|
with pytest.raises(AssertionError, match="wrong role assignment."):
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(16)), f"wrong role assignment."
|
|
|
|
with pytest.raises(AssertionError, match="wrong role assignment."):
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(32)), f"wrong role assignment."
|
|
|
|
with pytest.raises(AssertionError, match="wrong role assignment."):
|
|
assert check_if_participant_id_is_valid_standalone(participant_id, participant_type=ParticipantType(64)), f"wrong role assignment."
|
|
return
|