Ensure RedisIntegration is disabled, unless redis is installed#2504
Conversation
tests/test_api.py
Outdated
| @pytest.mark.skipif(REDIS_INSTALLED, reason="skipping because redis is installed") | ||
| def test_redis_disabled_when_not_installed(sentry_init): | ||
| sentry_init() | ||
|
|
||
| assert Hub.current.get_integration(RedisIntegration) is None |
There was a problem hiding this comment.
I was unsure about in which file this test should be placed. Is it ok to keep here, or should it go somewhere else?
There was a problem hiding this comment.
Maybe test_basics.py would be better? It already has some tests for integration enabling.
test_api.py is more for testing the global API (configure_scope, start_transaction, etc.; the stuff we surface via
sentry-python/sentry_sdk/__init__.py
Lines 13 to 43 in cb7299a
|
@szokeasaurusrex If I understood the issue correctly, the underlying problem is that in the Redis integration we raise sentry-python/sentry_sdk/integrations/redis/__init__.py Lines 275 to 278 in cb7299a |
|
@sentrivana Apparently it is also a more general issue. Integrations which conditionally raise
So, raising |
|
@szokeasaurusrex Gotcha, I see now. We still raise I'll give this a proper review tomorrow 👍🏻 |
Yes, and this is precisely the reason why the change here is needed |
sentrivana
left a comment
There was a problem hiding this comment.
Thanks for fixing this!
tests/integrations/test_init.py
Outdated
| return type(__value) == type(self) | ||
|
|
||
|
|
||
| def test_multiple_setup_integrations_calls(): |
There was a problem hiding this comment.
@sentrivana Do you think this new file is an appropriate place for this test?
There was a problem hiding this comment.
Why not just put it in tests/test_basics.py since we already have some integration tests in there?
Or maybe we could rename this new file from test_init.py to something more generic like test_common.py and also move other integrations-related tests from test_basics.py here.
There was a problem hiding this comment.
Okay, I'll put it in test_basics.py for now. Maybe in the future we could split out into a separate file, but I think moving everything over would be out of scope for this issue
|
@sentrivana I added a test to check that multiple |
|
Thanks for the fix! and for ensuring it covers everything I detailed in the issue 👍 |
This PR fixes a bug where the
RedisIntegrationwas showing up in the list of enabled integrations even whenrediswas not installed, and the integration should have been disabled.Fixes #1734