Esempio n. 1
0
    def set_state(self, state: Estado):
        self.events.append(Event(type=EventType.created))

        callback_helper.set_status_transaction(self.speid_id, state.value)
        self.estado = state

        self.events.append(Event(type=EventType.completed))
Esempio n. 2
0
def test_set_status_transaction(mock_set_status_transaction: MagicMock,
                                speid_id: str, state: str):
    params = dict(speid_id=speid_id, state=state)
    set_status_transaction(**params)

    task_params = mock_set_status_transaction.call_args[1]['kwargs']
    assert all(params[param] == task_params[param] for param in params)
Esempio n. 3
0
def callback_spei_transaction(transaction_id, transaction_status):
    """Establece el estado de la transacción,
    valores permitidos succeeded y failed"""
    transaction = Transaction.objects.get(id=transaction_id)
    if transaction_status == Estado.succeeded.value:
        transaction.estado = Estado.succeeded
        event_type = EventType.completed
    elif transaction_status == Estado.failed.value:
        transaction.estado = Estado.failed
        event_type = EventType.error
    else:
        raise ValueError('Invalid event type')
    set_status_transaction(transaction.speid_id, transaction.estado.value)
    transaction.events.append(
        Event(type=event_type, metadata=str('Reversed by SPEID command')))
    transaction.save()
Esempio n. 4
0
def test_set_status_transaction(mock_callback_api):
    res = set_status_transaction(123, 'success')
    assert res.status_code == 201
    assert json.loads(res.text)['status'] == 'succeeded'