Skip to content

Commit

Permalink
tests(code_mapping): Remove logging assertions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
armenzg committed Jan 12, 2023
1 parent eb2b1b4 commit 3190af2
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions tests/sentry/integrations/github/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from unittest.mock import MagicMock, patch
from urllib.parse import urlencode, urlparse

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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

0 comments on commit 3190af2

Please sign in to comment.