• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-eth-py / 13388974656

18 Feb 2025 10:56AM UTC coverage: 93.946% (-0.004%) from 93.95%
13388974656

Pull #1518

github

web-flow
Merge 4ce6371ba into 8b28bc770
Pull Request #1518: Add custom rate limit for aiohtpp

58 of 62 new or added lines in 3 files covered. (93.55%)

8 existing lines in 3 files now uncovered.

9543 of 10158 relevant lines covered (93.95%)

2.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/safe_eth/eth/tests/clients/test_rate_limit.py
1
import asyncio
3✔
2
import unittest
3✔
3

4
from safe_eth.eth.clients.rate_limiter import get_client_rate_limited
3✔
5

6

7
class TestRateLimit(unittest.IsolatedAsyncioTestCase):
3✔
8
    async def _make_request(self, rate_limited):
3✔
9
        """Helper to fetch the status code of a request."""
10
        try:
3✔
11
            async with await rate_limited.get(
3✔
12
                "https://safe-transaction-sepolia.safe.global/api/v1/about", timeout=5
13
            ) as response:
14
                return response
3✔
NEW
15
        except asyncio.TimeoutError:
×
NEW
16
            return None
×
17

18
    async def test_rate_limiter(self):
3✔
19
        rate_limited = get_client_rate_limited(
3✔
20
            "https://safe-transaction-sepolia.safe.global/", 5
21
        )
22
        tasks = [self._make_request(rate_limited) for _ in range(20)]
3✔
23
        responses = await asyncio.gather(*tasks)
3✔
24
        self.assertEqual(len(responses), 20)
3✔
25
        for response in responses:
3✔
26
            self.assertEqual(response.status, 200)  # Check the status code
3✔
27
            self.assertTrue(response.ok)
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc