|
1 |
| -import logging |
2 | 1 | from unittest.mock import MagicMock, patch
|
3 | 2 | from urllib.parse import urlencode, urlparse
|
4 | 3 |
|
@@ -72,10 +71,6 @@ class GitHubIntegrationTest(IntegrationTestCase):
|
72 | 71 | provider = GitHubIntegrationProvider
|
73 | 72 | base_url = "https://api.github.com"
|
74 | 73 |
|
75 |
| - @pytest.fixture(autouse=True) |
76 |
| - def inject_fixtures(self, caplog): |
77 |
| - self._caplog = caplog |
78 |
| - |
79 | 74 | def setUp(self):
|
80 | 75 | super().setUp()
|
81 | 76 |
|
@@ -643,33 +638,22 @@ def test_get_trees_for_org(self):
|
643 | 638 | ),
|
644 | 639 | }
|
645 | 640 |
|
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 |
671 | 656 |
|
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