forked from pantos-io/validatornode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rename secondary node's transfer submission function/task
- Loading branch information
1 parent
9ffc5e3
commit 4a82d0f
Showing
8 changed files
with
116 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
tests/business/transfers/test_submit_transfer_to_primary_node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import unittest.mock | ||
|
||
import celery.exceptions # type: ignore | ||
import pytest | ||
|
||
from pantos.validatornode.business.transfers import TransferInteractorError | ||
from pantos.validatornode.business.transfers import \ | ||
submit_transfer_to_primary_node_task | ||
|
||
|
||
@pytest.mark.parametrize('submission_completed', [True, False]) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.config', { | ||
'tasks': { | ||
'submit_transfer_to_primary_node': { | ||
'retry_interval_in_seconds': 120 | ||
} | ||
} | ||
}) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.TransferInteractor') | ||
def test_submit_transfer_to_primary_node_task_correct( | ||
mock_transfer_interactor, submission_completed, internal_transfer_id, | ||
cross_chain_transfer, cross_chain_transfer_dict): | ||
mock_transfer_interactor().submit_transfer_to_primary_node.return_value = \ | ||
submission_completed | ||
if submission_completed: | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
else: | ||
with pytest.raises(celery.exceptions.Retry): | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
mock_transfer_interactor().submit_transfer_to_primary_node.\ | ||
assert_called_once_with(internal_transfer_id, cross_chain_transfer) | ||
|
||
|
||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.config', { | ||
'tasks': { | ||
'submit_transfer_to_primary_node': { | ||
'retry_interval_after_error_in_seconds': 300 | ||
} | ||
} | ||
}) | ||
@unittest.mock.patch( | ||
'pantos.validatornode.business.transfers.TransferInteractor') | ||
def test_submit_transfer_to_primary_node_task_error(mock_transfer_interactor, | ||
internal_transfer_id, | ||
cross_chain_transfer, | ||
cross_chain_transfer_dict): | ||
mock_transfer_interactor().submit_transfer_to_primary_node.side_effect = \ | ||
TransferInteractorError('') | ||
with pytest.raises(TransferInteractorError): | ||
submit_transfer_to_primary_node_task(internal_transfer_id, | ||
cross_chain_transfer_dict) | ||
mock_transfer_interactor().submit_transfer_to_primary_node.\ | ||
assert_called_once_with(internal_transfer_id, cross_chain_transfer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.