From 92f66ada0d87b7574d00213e4d16fc13b8d5f28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s?= <7888669+moisses89@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:52:00 +0100 Subject: [PATCH] Restore weak test --- app/tests/workers/test_tasks.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/tests/workers/test_tasks.py b/app/tests/workers/test_tasks.py index f69e249..d9acb14 100644 --- a/app/tests/workers/test_tasks.py +++ b/app/tests/workers/test_tasks.py @@ -1,4 +1,3 @@ -import asyncio import json import unittest from typing import Any, Awaitable @@ -72,16 +71,12 @@ async def asyncSetUp(self): async def asyncTearDown(self): await super().asyncTearDown() - redis = get_redis() - redis.flushall() self.worker.stop() - async def _wait_tasks_execution(self): + def _wait_tasks_execution(self): redis_tasks = self.worker.broker.client.lrange("dramatiq:default", 0, -1) while len(redis_tasks) > 0: redis_tasks = self.worker.broker.client.lrange("dramatiq:default", 0, -1) - # TODO should check anyway the task status instead to randomly wait - await asyncio.sleep(2) @mock.patch.object(ContractMetadataService, "enabled_clients") @mock.patch.object( @@ -144,7 +139,6 @@ async def test_get_contract_metadata_task( async def test_get_contract_metadata_task_with_proxy( self, etherscan_get_contract_metadata_mock: MagicMock, session: AsyncSession ): - await AbiSource(name="Etherscan", url="").create(session) etherscan_get_contract_metadata_mock.side_effect = [ etherscan_proxy_metadata_mock, etherscan_metadata_mock, @@ -155,18 +149,16 @@ async def test_get_contract_metadata_task_with_proxy( get_contract_metadata_task.fn(address=contract_address, chain_id=chain_id) - await self._wait_tasks_execution() + self._wait_tasks_execution() - self.assertEqual(etherscan_get_contract_metadata_mock.call_count, 2) contract = await Contract.get_contract( session, HexBytes(contract_address), chain_id ) self.assertIsNotNone(contract) - self.assertEqual( - HexBytes(contract.implementation), HexBytes(proxy_implementation_address) - ) proxy_implementation = await Contract.get_contract( session, HexBytes(proxy_implementation_address), chain_id ) self.assertIsNotNone(proxy_implementation) + + self.assertEqual(etherscan_get_contract_metadata_mock.call_count, 2)