@@ -609,6 +609,7 @@ def get_installation_helper(self):
609609 def test_get_trees_for_org_works (self ):
610610 """Fetch the tree representation of a repo"""
611611 installation = self .get_installation_helper ()
612+ cache .clear ()
612613 self .set_rate_limit (MINIMUM_REQUESTS + 50 )
613614 expected_trees = {
614615 "Test-Organization/foo" : RepoTree (
@@ -643,8 +644,9 @@ def test_get_trees_for_org_works(self):
643644 def test_get_trees_for_org_prevent_exhaustion_some_repos (self ):
644645 """Some repos will hit the network but the rest will grab from the cache."""
645646 gh_org = "Test-Organization"
647+ repos_key = "githubtrees:repositories:Test-Organization"
648+ cache .clear ()
646649 installation = self .get_installation_helper ()
647-
648650 expected_trees = {
649651 f"{ gh_org } /xyz" : RepoTree (Repo (f"{ gh_org } /xyz" , "master" ), ["src/foo.py" ]),
650652 # This will have no files because we will hit the minimum remaining requests floor
@@ -655,8 +657,15 @@ def test_get_trees_for_org_prevent_exhaustion_some_repos(self):
655657 with patch ("sentry.integrations.github.client.MINIMUM_REQUESTS" , new = 5 , autospec = False ):
656658 # We start with one request left before reaching the minimum remaining requests floor
657659 self .set_rate_limit (remaining = 6 )
660+ assert cache .get (repos_key ) is None
658661 trees = installation .get_trees_for_org ()
659662 assert trees == expected_trees # xyz will have files but not foo
663+ assert cache .get (repos_key ) == [
664+ {"full_name" : "Test-Organization/xyz" , "default_branch" : "master" },
665+ {"full_name" : "Test-Organization/foo" , "default_branch" : "master" },
666+ {"full_name" : "Test-Organization/bar" , "default_branch" : "main" },
667+ {"full_name" : "Test-Organization/baz" , "default_branch" : "master" },
668+ ]
660669
661670 # Another call should not make us loose the files for xyz
662671 self .set_rate_limit (remaining = 5 )
0 commit comments