@@ -36,12 +36,13 @@ class TestSearchIssues(unittest.TestCase):
3636 module to mock the GitHub API and test the function in isolation.
3737
3838 Methods:
39- test_search_issues: Test that search_issues returns the correct issues.
39+ test_search_issues_with_owner_and_repository: Test that search_issues with owner/repo returns the correct issues.
40+ test_search_issues_with_just_owner_or_org: Test that search_issues with just an owner/org returns the correct issues.
4041
4142 """
4243
43- def test_search_issues (self ):
44- """Test that search_issues returns the correct issues."""
44+ def test_search_issues_with_owner_and_repository (self ):
45+ """Test that search_issues with owner/repo returns the correct issues."""
4546
4647 # Set up the mock GitHub connection object
4748 mock_issues = [
@@ -63,6 +64,30 @@ def test_search_issues(self):
6364 issues = search_issues ("is:open" , mock_connection , owners_and_repositories )
6465 self .assertEqual (issues , mock_issues )
6566
67+ def test_search_issues_with_just_owner_or_org (self ):
68+ """Test that search_issues with just an owner/org returns the correct issues."""
69+
70+ # Set up the mock GitHub connection object
71+ mock_issues = [
72+ MagicMock (title = "Issue 1" ),
73+ MagicMock (title = "Issue 2" ),
74+ MagicMock (title = "Issue 3" ),
75+ ]
76+
77+ # simulating github3.structs.SearchIterator return value
78+ mock_search_result = MagicMock ()
79+ mock_search_result .__iter__ .return_value = iter (mock_issues )
80+ mock_search_result .ratelimit_remaining = 30
81+
82+ mock_connection = MagicMock ()
83+ mock_connection .search_issues .return_value = mock_search_result
84+
85+ # Call search_issues and check that it returns the correct issues
86+ org = {"owner" : "org1" }
87+ owners = [org ]
88+ issues = search_issues ("is:open" , mock_connection , owners )
89+ self .assertEqual (issues , mock_issues )
90+
6691
6792class TestGetOwnerAndRepository (unittest .TestCase ):
6893 """Unit tests for the get_owners_and_repositories function.
@@ -84,7 +109,7 @@ def test_get_owners_with_owner_and_repo_in_query(self):
84109 self .assertEqual (result [0 ].get ("owner" ), "owner1" )
85110 self .assertEqual (result [0 ].get ("repository" ), "repo1" )
86111
87- def test_get_owner_and_repositories_with_repo_in_query (self ):
112+ def test_get_owner_and_repositories_without_repo_in_query (self ):
88113 """Test get just owner."""
89114 result = get_owners_and_repositories ("org:owner1" )
90115 self .assertEqual (result [0 ].get ("owner" ), "owner1" )
0 commit comments