Skip to content

Commit 3190af2

Browse files
committed
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.
1 parent eb2b1b4 commit 3190af2

File tree

1 file changed

+18
-34
lines changed

1 file changed

+18
-34
lines changed

tests/sentry/integrations/github/test_integration.py

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
from unittest.mock import MagicMock, patch
32
from urllib.parse import urlencode, urlparse
43

@@ -72,10 +71,6 @@ class GitHubIntegrationTest(IntegrationTestCase):
7271
provider = GitHubIntegrationProvider
7372
base_url = "https://api.github.com"
7473

75-
@pytest.fixture(autouse=True)
76-
def inject_fixtures(self, caplog):
77-
self._caplog = caplog
78-
7974
def setUp(self):
8075
super().setUp()
8176

@@ -643,33 +638,22 @@ def test_get_trees_for_org(self):
643638
),
644639
}
645640

646-
with patch("sentry.integrations.utils.code_mapping.logger") as logger:
647-
assert not cache.get("githubtrees:repositories:Test-Organization")
648-
# This allows checking for caching related output
649-
self._caplog.set_level(logging.INFO, logger="sentry")
650-
# Check that the cache is clear
651-
repo_key = "github:repo:Test-Organization/foo:source-code"
652-
assert cache.get("githubtrees:repositories:foo:Test-Organization") is None
653-
assert cache.get(repo_key) is None
654-
trees = installation.get_trees_for_org()
655-
656-
# These checks are useful since they will be available in the GCP logs
657-
for msg in [
658-
"The Github App does not have access to Test-Organization/baz.",
659-
"Caching trees for Test-Organization",
660-
]:
661-
assert logger.info.called_with(msg)
662-
663-
assert cache.get("githubtrees:repositories:foo:Test-Organization") == [
664-
{"full_name": "Test-Organization/foo", "default_branch": "master"},
665-
{"full_name": "Test-Organization/bar", "default_branch": "main"},
666-
{"full_name": "Test-Organization/baz", "default_branch": "master"},
667-
{"full_name": "Test-Organization/xyz", "default_branch": "master"},
668-
]
669-
assert cache.get(repo_key) == ["src/sentry/api/endpoints/auth_login.py"]
670-
assert trees == expected_trees
641+
assert not cache.get("githubtrees:repositories:Test-Organization")
642+
# Check that the cache is clear
643+
repo_key = "github:repo:Test-Organization/foo:source-code"
644+
assert cache.get("githubtrees:repositories:foo:Test-Organization") is None
645+
assert cache.get(repo_key) is None
646+
trees = installation.get_trees_for_org()
647+
648+
assert cache.get("githubtrees:repositories:foo:Test-Organization") == [
649+
{"full_name": "Test-Organization/foo", "default_branch": "master"},
650+
{"full_name": "Test-Organization/bar", "default_branch": "main"},
651+
{"full_name": "Test-Organization/baz", "default_branch": "master"},
652+
{"full_name": "Test-Organization/xyz", "default_branch": "master"},
653+
]
654+
assert cache.get(repo_key) == ["src/sentry/api/endpoints/auth_login.py"]
655+
assert trees == expected_trees
671656

672-
# Calling a second time should produce the same results
673-
trees = installation.get_trees_for_org()
674-
assert logger.info.called_with("Using cached trees for Test-Organization.")
675-
assert trees == expected_trees
657+
# Calling a second time should produce the same results
658+
trees = installation.get_trees_for_org()
659+
assert trees == expected_trees

0 commit comments

Comments
 (0)