SIENTIAPDE-1975: Sonar fixes in the NATS consumer tests

- One call per pytest.raises block (S5778): build the guarded start()
  before the block and nest the patch outside it.
- The NATS callbacks stay async on purpose: nats-py rejects callbacks
  that are not coroutine functions. Comment it and assert it in the
  callback test, so nobody drops the async keyword to please S7503.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Eduardo Rios
2026-10-14 12:20:30 -03:00
parent bf287a688c
commit e94b489196
2 changed files with 11 additions and 2 deletions

View File

@@ -94,6 +94,8 @@ class NatsWriteConsumer:
f'{traceback.format_exc()}'
)
# These stay async with nothing to await: nats-py rejects callbacks that are not
# coroutine functions (InvalidCallbackTypeError on connect).
async def _on_error(self, e: Exception) -> None:
self.logger.warning(f'NATS error: {type(e).__name__} {e}')