From 3190af2ee9b9d0be446d4dce80f7eec8995adf4c Mon Sep 17 00:00:00 2001 From: Armen Zambrano G Date: Wed, 11 Jan 2023 16:31:40 -0800 Subject: [PATCH] tests(code_mapping): Remove logging assertions In #42712 it was reported that the usage of `called_with` is not correct and it indeed does not work. This part of the test is not as important as it used to be. We can remove it. --- .../integrations/github/test_integration.py | 52 +++++++------------ 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/tests/sentry/integrations/github/test_integration.py b/tests/sentry/integrations/github/test_integration.py index f22f7574a02ada..029965b8c0ab9c 100644 --- a/tests/sentry/integrations/github/test_integration.py +++ b/tests/sentry/integrations/github/test_integration.py @@ -1,4 +1,3 @@ -import logging from unittest.mock import MagicMock, patch from urllib.parse import urlencode, urlparse @@ -72,10 +71,6 @@ class GitHubIntegrationTest(IntegrationTestCase): provider = GitHubIntegrationProvider base_url = "https://api.github.com" - @pytest.fixture(autouse=True) - def inject_fixtures(self, caplog): - self._caplog = caplog - def setUp(self): super().setUp() @@ -643,33 +638,22 @@ def test_get_trees_for_org(self): ), } - with patch("sentry.integrations.utils.code_mapping.logger") as logger: - assert not cache.get("githubtrees:repositories:Test-Organization") - # This allows checking for caching related output - self._caplog.set_level(logging.INFO, logger="sentry") - # Check that the cache is clear - repo_key = "github:repo:Test-Organization/foo:source-code" - assert cache.get("githubtrees:repositories:foo:Test-Organization") is None - assert cache.get(repo_key) is None - trees = installation.get_trees_for_org() - - # These checks are useful since they will be available in the GCP logs - for msg in [ - "The Github App does not have access to Test-Organization/baz.", - "Caching trees for Test-Organization", - ]: - assert logger.info.called_with(msg) - - assert cache.get("githubtrees:repositories:foo:Test-Organization") == [ - {"full_name": "Test-Organization/foo", "default_branch": "master"}, - {"full_name": "Test-Organization/bar", "default_branch": "main"}, - {"full_name": "Test-Organization/baz", "default_branch": "master"}, - {"full_name": "Test-Organization/xyz", "default_branch": "master"}, - ] - assert cache.get(repo_key) == ["src/sentry/api/endpoints/auth_login.py"] - assert trees == expected_trees + assert not cache.get("githubtrees:repositories:Test-Organization") + # Check that the cache is clear + repo_key = "github:repo:Test-Organization/foo:source-code" + assert cache.get("githubtrees:repositories:foo:Test-Organization") is None + assert cache.get(repo_key) is None + trees = installation.get_trees_for_org() + + assert cache.get("githubtrees:repositories:foo:Test-Organization") == [ + {"full_name": "Test-Organization/foo", "default_branch": "master"}, + {"full_name": "Test-Organization/bar", "default_branch": "main"}, + {"full_name": "Test-Organization/baz", "default_branch": "master"}, + {"full_name": "Test-Organization/xyz", "default_branch": "master"}, + ] + assert cache.get(repo_key) == ["src/sentry/api/endpoints/auth_login.py"] + assert trees == expected_trees - # Calling a second time should produce the same results - trees = installation.get_trees_for_org() - assert logger.info.called_with("Using cached trees for Test-Organization.") - assert trees == expected_trees + # Calling a second time should produce the same results + trees = installation.get_trees_for_org() + assert trees == expected_trees