def build_transfer(**kwargs) -> Transfer: return Transfer( conversation_id=kwargs.get("conversation_id", a_string(36)), sla_duration=kwargs.get("sla_duration", a_duration()), requesting_practice=kwargs.get( "requesting_practice", Practice(asid=a_string(12), supplier=a_string(12), ods_code=a_string(4)), ), sending_practice=kwargs.get( "sending_practice", Practice(asid=a_string(12), supplier=a_string(12), ods_code=a_string(4)), ), sender_error_codes=kwargs.get("sender_error_codes", []), final_error_codes=kwargs.get("final_error_codes", []), intermediate_error_codes=kwargs.get("intermediate_error_codes", []), outcome=kwargs.get( "outcome", TransferOutcome(status=TransferStatus.INTEGRATED_ON_TIME, failure_reason=None), ), date_requested=kwargs.get("date_requested", a_datetime()), date_completed=kwargs.get("date_completed", None), last_sender_message_timestamp=None, )
def a_supressed_transfer(**kwargs): return build_transfer( outcome=TransferOutcome( status=TransferStatus.INTEGRATED_ON_TIME, failure_reason=None, ), final_error_codes=[15], sla_duration=kwargs.get("sla_duration", a_duration(max_length=604800)), )
def build_transfer(**kwargs): return Transfer( conversation_id=kwargs.get("conversation_id", a_string(36)), sla_duration=kwargs.get("sla_duration", a_duration()), requesting_practice_ods=kwargs.get("requesting_practice_ods", a_string(6)), sending_practice_ods=kwargs.get("sending_practice_ods", a_string(6)), error_code=kwargs.get("error_code", None), pending=kwargs.get("pending", False), )
def test_returns_transfer_status_technical_failure_with_reason( test_case, expected_reason): gp2gp_messages: List[Message] = test_case() conversation = Gp2gpConversation( gp2gp_messages, mock_gp2gp_conversation_observability_probe) actual = TransferOutcome.from_gp2gp_conversation(conversation, a_duration()) assert actual.status == TransferStatus.TECHNICAL_FAILURE assert actual.failure_reason == expected_reason
def test_returns_correct_transfer_outcome_if_fatal_sender_error_code_present( fatal_sender_error_code, ): gp2gp_messages: List[Message] = test_cases.request_acknowledged_with_error( error_code=fatal_sender_error_code) conversation = Gp2gpConversation( gp2gp_messages, mock_gp2gp_conversation_observability_probe) actual = TransferOutcome.from_gp2gp_conversation(conversation, a_duration()) assert actual.status == TransferStatus.TECHNICAL_FAILURE assert actual.failure_reason == TransferFailureReason.FATAL_SENDER_ERROR
def test_returns_correct_transfer_outcome_given_multiple_conflicting_sender_acks( ): a_fatal_sender_error = choice(FATAL_SENDER_ERROR_CODES) gp2gp_messages: List[ Message] = test_cases.multiple_sender_acknowledgements( error_codes=[None, a_fatal_sender_error]) conversation = Gp2gpConversation( gp2gp_messages, mock_gp2gp_conversation_observability_probe) actual = TransferOutcome.from_gp2gp_conversation(conversation, a_duration()) assert actual.status == TransferStatus.TECHNICAL_FAILURE assert actual.failure_reason == TransferFailureReason.FATAL_SENDER_ERROR
def build_transfer(**kwargs): return Transfer( conversation_id=kwargs.get("conversation_id", a_string(36)), sla_duration=kwargs.get("sla_duration", a_duration()), requesting_practice_asid=kwargs.get("requesting_practice_asid", a_string(12)), sending_practice_asid=kwargs.get("sending_practice_asid", a_string(12)), requesting_supplier=kwargs.get("requesting_supplier", a_string(12)), sending_supplier=kwargs.get("sending_supplier", a_string(12)), sender_error_code=kwargs.get("sender_error_code", None), final_error_code=kwargs.get("final_error_code", None), intermediate_error_codes=kwargs.get("intermediate_error_codes", []), status=kwargs.get("status", TransferStatus.PENDING), date_requested=kwargs.get("date_requested", a_datetime()), date_completed=kwargs.get("date_completed", None), )
def build_transfers(**kwargs) -> List[Transfer]: transfer_count = kwargs.get("transfer_count", an_integer(2, 7)) integrated_transfer_count = kwargs.get("integrated_transfer_count", 0) failed_transfer_count = kwargs.get("failed_transfer_count", 0) sla_duration = kwargs.get("sla_duration", a_duration()) transfers: List[Transfer] = [] transfers.extend((build_transfer() for _ in range(transfer_count))) transfers.extend( ( an_integrated_transfer(sla_duration=sla_duration) for _ in range(integrated_transfer_count) ) ) transfers.extend((a_failed_transfer() for _ in range(failed_transfer_count))) return transfers
def an_integrated_transfer(**kwargs): return build_transfer( outcome=TransferOutcome(status=TransferStatus.INTEGRATED_ON_TIME, failure_reason=None), sla_duration=kwargs.get("sla_duration", a_duration(max_length=604800)), )
def an_integrated_transfer(**kwargs): return build_transfer( status=TransferStatus.INTEGRATED, sla_duration=kwargs.get("sla_duration", a_duration()) )