Skip to content

Commit

Permalink
fix test_txs_generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ape364 committed May 29, 2024
1 parent 83b153c commit 9f09bfd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/extra/generators/test_blocks_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from unittest.mock import AsyncMock
from unittest.mock import AsyncMock, Mock

import pytest

Expand Down Expand Up @@ -113,9 +113,19 @@ async def test_fetch_blocks_range_no_txs(blocks_parser, api_method):
assert transfers == []


async def test_txs_generator_success(blocks_parser, api_method):
api_method.return_value = [{'blockNumber': 200, 'transfers': [{'value': 100}]}]
async def test_txs_generator(blocks_parser, api_method):
api_method.side_effect = [
EtherscanClientApiError('Test exception', 'result'),
[{'blockNumber': 200, 'transfers': [{'value': 100}]}],
]
blocks_parser._blocks_range.limit.reduce = Mock()
blocks_parser._blocks_range.limit.restore = Mock()

transfers = []
async for transfer in blocks_parser.txs_generator():
transfers.append(transfer)

blocks_parser._blocks_range.limit.reduce.assert_called_once()
blocks_parser._blocks_range.limit.restore.assert_called_once()

assert transfers == [{'blockNumber': 200, 'transfers': [{'value': 100}]}]

0 comments on commit 9f09bfd

Please sign in to comment.