def test_failed_payment_exception_400(send_op_result): request_id = 'request-id' pay_bill(request_id, 'internet_telmex', '2424240024') assert send_op_result.called op_info = send_op_result.call_args[0][0] assert op_info.request_id == request_id assert op_info.tran_type == OperationType.payment assert op_info.status == OperationStatus.failed
def test_pay_bill_with_non_min_value(send_op_result): request_id = 'request-id' pay_bill(request_id, 'satellite_tv_sky', '501000000007', 1) assert send_op_result.called op_info = send_op_result.call_args[0][0] assert op_info.request_id == request_id assert op_info.tran_type == OperationType.payment assert op_info.status == OperationStatus.failed assert op_info.notification == 'El monto a pagar es inválido.'
def test_successful_payment_with_amount(send_op_result): request_id = 'request-id' pay_bill(request_id, 'satellite_tv_sky', '501000000007', 57000) assert send_op_result.called op_info = send_op_result.call_args[0][0] assert op_info.request_id == request_id assert op_info.tran_type == OperationType.payment assert op_info.status == OperationStatus.success assert type(op_info.operation.id) is int assert op_info.operation.status == 'fulfilled'
def test_refund_payment_handles_error(mock_pay_bill, mock_send_op_result): request_id = 'testid' task_info = dict(request_id=request_id, ) save_task_info(task_info) runner = CliRunner() with pytest.raises(Exception): pay_bill(request_id, 'internet_telmex', '2424240024') result = runner.invoke(change_status, [request_id, 'failed']) get_task_info(dict(request_id=request_id)) assert result.output == 'connection error try again\n'
def test_send_operation_result_callback_failed_with_connection_error( send_op_result): request_id = 'request-id' pay_bill(request_id, 'satellite_tv_sky', '501000000007') assert send_op_result.called op_info = send_op_result.call_args[0][0] assert op_info.request_id == request_id assert op_info.tran_type == OperationType.payment assert op_info.status == OperationStatus.success assert type(op_info.operation.id) is int assert op_info.operation.status == 'fulfilled'
def test_set_status_failed_creates_op_info(mock_pay_bill, mock_send_op_result): request_id = 'request-id2' task_info = dict(request_id=request_id, ) save_task_info(task_info) runner = CliRunner() with pytest.raises(Exception): pay_bill(request_id, 'internet_telmex', '2424240024') result = runner.invoke(change_status, [request_id, 'failed']) assert result.exit_code == 0 transaction = get_task_info(dict(request_id=request_id)) assert transaction['op_info'] is not None assert transaction['op_info']['status'] == 'failed' assert mock_send_op_result.called
def test_success_and_create_op_info(mock_pay_bill, mock_send_op_result): request_id = 'idtest' task_info = dict(request_id=request_id, ) save_task_info(task_info) runner = CliRunner() with pytest.raises(Exception): pay_bill(request_id, 'internet_telmex', '2424240024') result = runner.invoke(change_status, [request_id, 'success'], input='arcus-id\n100') assert result.exit_code == 0 transaction = get_task_info(dict(request_id=request_id)) assert transaction['op_info']['operation']['amount'] == 100 assert transaction['op_info']['operation']['id'] == 'arcus-id'