diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-09 09:49:55 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-09 09:49:55 +0200 |
| commit | 01e69c492a5771939d1b1a8efd93f3ebb7cbe72c (patch) | |
| tree | ab06cce602d0ef66dd6764e960809d14f307f244 | |
| parent | 8df4c6cd0867feb8bca22647ed024349442528da (diff) | |
| download | abusectl-01e69c492a5771939d1b1a8efd93f3ebb7cbe72c.tar.gz abusectl-01e69c492a5771939d1b1a8efd93f3ebb7cbe72c.zip | |
test: make the offline resolve check tamper-evident
The test asserted only that resolve() returned one entry. It returns one
entry whether the injected fetch answered or the real transport was
blocked, because resolve() records a transport failure as a per-entry
error rather than raising. So the assertion would have stayed green if
someone removed the injection, which is the one thing the test exists to
notice.
It now asserts the handle that only the injected fetch can produce.
Removing the injection fails with KeyError: 'handle'.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wrfqr2xqQfhtXCscU7zrdz
| -rw-r--r-- | tests/test_offline.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_offline.py b/tests/test_offline.py index dfb9965..19d9cee 100644 --- a/tests/test_offline.py +++ b/tests/test_offline.py @@ -65,7 +65,14 @@ class NothingOpensASocket(unittest.TestCase): iocs, bootstraps=bootstraps, fetch=lambda url: {"handle": "NET-1", "entities": []}, ) + # Assert on the handle the injected fetch produced, not merely on + # the length. resolve() records a transport failure as a per-entry + # error rather than raising, so an entry exists either way: a test + # counting entries would stay green if the injection were removed + # and the real transport were blocked, which is the one thing this + # test is here to notice. self.assertEqual(len(result), 1) + self.assertEqual(result[0]["handle"], "NET-1") def test_the_real_transport_is_never_the_default_in_a_test(self): """Sanity: http_fetch exists and is the documented default.""" |
