@@ -679,40 +679,16 @@ def test_get_repositories_search_param(self) -> None:
679679
680680 @responses .activate
681681 def test_get_repositories_accessible_only (self ) -> None :
682- """accessible_only+query uses Search API filtered by cached accessible IDs ."""
682+ """accessible_only+query filters cached repo list locally ."""
683683 with self .tasks ():
684684 self .assert_setup_flow ()
685685
686- querystring = urlencode ({"q" : "fork:true org:Test Organization foo" })
687- responses .add (
688- responses .GET ,
689- f"{ self .base_url } /search/repositories?{ querystring } " ,
690- json = {
691- "items" : [
692- {
693- "id" : 1296269 ,
694- "name" : "foo" ,
695- "full_name" : "Test-Organization/foo" ,
696- "default_branch" : "master" ,
697- },
698- {
699- "id" : 9999999 ,
700- "name" : "foo-external" ,
701- "full_name" : "Other-Org/foo-external" ,
702- "default_branch" : "main" ,
703- },
704- ]
705- },
706- )
707-
708686 integration = Integration .objects .get (provider = self .provider .key )
709687 installation = get_installation_of_type (
710688 GitHubIntegration , integration , self .organization .id
711689 )
712690
713691 result = installation .get_repositories ("foo" , accessible_only = True )
714- # foo-external is filtered out: its id (9999999) is the archived repo's id,
715- # which is excluded from the accessible set
716692 assert result == [
717693 {
718694 "name" : "foo" ,
@@ -724,17 +700,10 @@ def test_get_repositories_accessible_only(self) -> None:
724700
725701 @responses .activate
726702 def test_get_repositories_accessible_only_no_match (self ) -> None :
727- """When accessible_only=True and search returns no accessible repos, returns empty list."""
703+ """accessible_only+query with no matching repos returns empty list."""
728704 with self .tasks ():
729705 self .assert_setup_flow ()
730706
731- querystring = urlencode ({"q" : "fork:true org:Test Organization nonexistent" })
732- responses .add (
733- responses .GET ,
734- f"{ self .base_url } /search/repositories?{ querystring } " ,
735- json = {"items" : []},
736- )
737-
738707 integration = Integration .objects .get (provider = self .provider .key )
739708 installation = get_installation_of_type (
740709 GitHubIntegration , integration , self .organization .id
@@ -744,41 +713,25 @@ def test_get_repositories_accessible_only_no_match(self) -> None:
744713 assert result == []
745714
746715 @responses .activate
747- def test_get_repositories_accessible_only_caches_ids (self ) -> None :
748- """Second accessible_only call uses cached IDs instead of re-fetching all repos ."""
716+ def test_get_repositories_accessible_only_caches_repos (self ) -> None :
717+ """Second accessible_only call uses cached repos instead of re-fetching from GitHub ."""
749718 with self .tasks ():
750719 self .assert_setup_flow ()
751720
752- querystring = urlencode ({"q" : "fork:true org:Test Organization foo" })
753- responses .add (
754- responses .GET ,
755- f"{ self .base_url } /search/repositories?{ querystring } " ,
756- json = {
757- "items" : [
758- {
759- "id" : 1296269 ,
760- "name" : "foo" ,
761- "full_name" : "Test-Organization/foo" ,
762- "default_branch" : "master" ,
763- },
764- ]
765- },
766- )
767-
768721 integration = Integration .objects .get (provider = self .provider .key )
769722 installation = get_installation_of_type (
770723 GitHubIntegration , integration , self .organization .id
771724 )
772725
773- # First call: cache miss, fetches /installation/repositories + search
726+ # First call: cache miss, fetches /installation/repositories
774727 result1 = installation .get_repositories ("foo" , accessible_only = True )
775728 install_repo_calls = [
776729 c for c in responses .calls if "/installation/repositories" in c .request .url
777730 ]
778731 first_fetch_count = len (install_repo_calls )
779732 assert first_fetch_count > 0
780733
781- # Second call: cache hit, only search is called ( no new /installation/repositories)
734+ # Second call: cache hit, no new /installation/repositories calls
782735 result2 = installation .get_repositories ("foo" , accessible_only = True )
783736 install_repo_calls = [
784737 c for c in responses .calls if "/installation/repositories" in c .request .url
0 commit comments