Why this matters
EC2 metadata lookup should fail quietly. This is a good isolated test task with no product behavior risk.
Files to touch
tests/app/remote/test_server.py
Exactly what to do
- Add tests for
_imds_token() when urlopen() raises URLError.
- Add tests for
_imds_get() when urlopen() raises TimeoutError or OSError.
- Assert both helpers return
None.
- Keep the tests local and fully mocked.
Done when
- IMDS helpers have explicit coverage for the failure paths listed in the code
- No network is used in tests
Verify
python -m pytest tests/app/remote/test_server.py -q
Why this matters
EC2 metadata lookup should fail quietly. This is a good isolated test task with no product behavior risk.
Files to touch
tests/app/remote/test_server.pyExactly what to do
_imds_token()whenurlopen()raisesURLError._imds_get()whenurlopen()raisesTimeoutErrororOSError.None.Done when
Verify