2424from unittest .mock import Mock , patch , MagicMock
2525from datetime import datetime
2626
27- # Add parent directory to path for imports
28- sys .path .insert (0 , str (Path (__file__ ).parent .parent / "cli" ))
29-
3027try :
3128 from github import Github , GithubException
3229 PYGITHUB_AVAILABLE = True
@@ -40,7 +37,7 @@ class TestGitHubScraperInitialization(unittest.TestCase):
4037 def setUp (self ):
4138 if not PYGITHUB_AVAILABLE :
4239 self .skipTest ("PyGithub not installed" )
43- from github_scraper import GitHubScraper
40+ from skill_seekers . cli . github_scraper import GitHubScraper
4441 self .GitHubScraper = GitHubScraper
4542
4643 # Create temporary directory for test output
@@ -74,7 +71,7 @@ def test_init_with_token_from_config(self):
7471 'github_token' : 'test_token_123'
7572 }
7673
77- with patch ('github_scraper.Github' ) as mock_github :
74+ with patch ('skill_seekers.cli. github_scraper.Github' ) as mock_github :
7875 scraper = self .GitHubScraper (config )
7976 mock_github .assert_called_once_with ('test_token_123' )
8077
@@ -87,7 +84,7 @@ def test_init_with_token_from_env(self):
8784 }
8885
8986 with patch .dict (os .environ , {'GITHUB_TOKEN' : 'env_token_456' }):
90- with patch ('github_scraper.Github' ) as mock_github :
87+ with patch ('skill_seekers.cli. github_scraper.Github' ) as mock_github :
9188 scraper = self .GitHubScraper (config )
9289 mock_github .assert_called_once_with ('env_token_456' )
9390
@@ -99,7 +96,7 @@ def test_init_without_token(self):
9996 'github_token' : None
10097 }
10198
102- with patch ('github_scraper.Github' ) as mock_github :
99+ with patch ('skill_seekers.cli. github_scraper.Github' ) as mock_github :
103100 with patch .dict (os .environ , {}, clear = True ):
104101 scraper = self .GitHubScraper (config )
105102 # Should create unauthenticated client
@@ -125,7 +122,7 @@ class TestREADMEExtraction(unittest.TestCase):
125122 def setUp (self ):
126123 if not PYGITHUB_AVAILABLE :
127124 self .skipTest ("PyGithub not installed" )
128- from github_scraper import GitHubScraper
125+ from skill_seekers . cli . github_scraper import GitHubScraper
129126 self .GitHubScraper = GitHubScraper
130127
131128 def test_extract_readme_success (self ):
@@ -139,7 +136,7 @@ def test_extract_readme_success(self):
139136 mock_content = Mock ()
140137 mock_content .decoded_content = b'# React\n \n A JavaScript library'
141138
142- with patch ('github_scraper.Github' ):
139+ with patch ('skill_seekers.cli. github_scraper.Github' ):
143140 scraper = self .GitHubScraper (config )
144141 scraper .repo = Mock ()
145142 scraper .repo .get_contents .return_value = mock_content
@@ -157,7 +154,7 @@ def test_extract_readme_tries_multiple_locations(self):
157154 'github_token' : None
158155 }
159156
160- with patch ('github_scraper.Github' ):
157+ with patch ('skill_seekers.cli. github_scraper.Github' ):
161158 scraper = self .GitHubScraper (config )
162159 scraper .repo = Mock ()
163160
@@ -184,7 +181,7 @@ def test_extract_readme_not_found(self):
184181 'github_token' : None
185182 }
186183
187- with patch ('github_scraper.Github' ):
184+ with patch ('skill_seekers.cli. github_scraper.Github' ):
188185 scraper = self .GitHubScraper (config )
189186 scraper .repo = Mock ()
190187 scraper .repo .get_contents .side_effect = GithubException (404 , 'Not found' )
@@ -201,7 +198,7 @@ class TestLanguageDetection(unittest.TestCase):
201198 def setUp (self ):
202199 if not PYGITHUB_AVAILABLE :
203200 self .skipTest ("PyGithub not installed" )
204- from github_scraper import GitHubScraper
201+ from skill_seekers . cli . github_scraper import GitHubScraper
205202 self .GitHubScraper = GitHubScraper
206203
207204 def test_extract_languages_success (self ):
@@ -212,7 +209,7 @@ def test_extract_languages_success(self):
212209 'github_token' : None
213210 }
214211
215- with patch ('github_scraper.Github' ):
212+ with patch ('skill_seekers.cli. github_scraper.Github' ):
216213 scraper = self .GitHubScraper (config )
217214 scraper .repo = Mock ()
218215 scraper .repo .get_languages .return_value = {
@@ -243,7 +240,7 @@ def test_extract_languages_empty(self):
243240 'github_token' : None
244241 }
245242
246- with patch ('github_scraper.Github' ):
243+ with patch ('skill_seekers.cli. github_scraper.Github' ):
247244 scraper = self .GitHubScraper (config )
248245 scraper .repo = Mock ()
249246 scraper .repo .get_languages .return_value = {}
@@ -260,7 +257,7 @@ class TestIssuesExtraction(unittest.TestCase):
260257 def setUp (self ):
261258 if not PYGITHUB_AVAILABLE :
262259 self .skipTest ("PyGithub not installed" )
263- from github_scraper import GitHubScraper
260+ from skill_seekers . cli . github_scraper import GitHubScraper
264261 self .GitHubScraper = GitHubScraper
265262
266263 def test_extract_issues_success (self ):
@@ -310,7 +307,7 @@ def test_extract_issues_success(self):
310307 mock_issue2 .body = 'Feature description'
311308 mock_issue2 .pull_request = None
312309
313- with patch ('github_scraper.Github' ):
310+ with patch ('skill_seekers.cli. github_scraper.Github' ):
314311 scraper = self .GitHubScraper (config )
315312 scraper .repo = Mock ()
316313 scraper .repo .get_issues .return_value = [mock_issue1 , mock_issue2 ]
@@ -361,7 +358,7 @@ def test_extract_issues_filters_pull_requests(self):
361358 mock_pr .title = 'Pull request'
362359 mock_pr .pull_request = Mock () # Has pull_request attribute
363360
364- with patch ('github_scraper.Github' ):
361+ with patch ('skill_seekers.cli. github_scraper.Github' ):
365362 scraper = self .GitHubScraper (config )
366363 scraper .repo = Mock ()
367364 scraper .repo .get_issues .return_value = [mock_issue , mock_pr ]
@@ -399,7 +396,7 @@ def test_extract_issues_respects_max_limit(self):
399396 mock_issue .pull_request = None
400397 mock_issues .append (mock_issue )
401398
402- with patch ('github_scraper.Github' ):
399+ with patch ('skill_seekers.cli. github_scraper.Github' ):
403400 scraper = self .GitHubScraper (config )
404401 scraper .repo = Mock ()
405402 scraper .repo .get_issues .return_value = mock_issues
@@ -417,7 +414,7 @@ class TestChangelogExtraction(unittest.TestCase):
417414 def setUp (self ):
418415 if not PYGITHUB_AVAILABLE :
419416 self .skipTest ("PyGithub not installed" )
420- from github_scraper import GitHubScraper
417+ from skill_seekers . cli . github_scraper import GitHubScraper
421418 self .GitHubScraper = GitHubScraper
422419
423420 def test_extract_changelog_success (self ):
@@ -431,7 +428,7 @@ def test_extract_changelog_success(self):
431428 mock_content = Mock ()
432429 mock_content .decoded_content = b'# Changelog\n \n ## v1.0.0\n - Initial release'
433430
434- with patch ('github_scraper.Github' ):
431+ with patch ('skill_seekers.cli. github_scraper.Github' ):
435432 scraper = self .GitHubScraper (config )
436433 scraper .repo = Mock ()
437434 scraper .repo .get_contents .return_value = mock_content
@@ -449,7 +446,7 @@ def test_extract_changelog_tries_multiple_locations(self):
449446 'github_token' : None
450447 }
451448
452- with patch ('github_scraper.Github' ):
449+ with patch ('skill_seekers.cli. github_scraper.Github' ):
453450 scraper = self .GitHubScraper (config )
454451 scraper .repo = Mock ()
455452
@@ -479,7 +476,7 @@ def test_extract_changelog_not_found(self):
479476 'github_token' : None
480477 }
481478
482- with patch ('github_scraper.Github' ):
479+ with patch ('skill_seekers.cli. github_scraper.Github' ):
483480 scraper = self .GitHubScraper (config )
484481 scraper .repo = Mock ()
485482 scraper .repo .get_contents .side_effect = GithubException (404 , 'Not found' )
@@ -496,7 +493,7 @@ class TestReleasesExtraction(unittest.TestCase):
496493 def setUp (self ):
497494 if not PYGITHUB_AVAILABLE :
498495 self .skipTest ("PyGithub not installed" )
499- from github_scraper import GitHubScraper
496+ from skill_seekers . cli . github_scraper import GitHubScraper
500497 self .GitHubScraper = GitHubScraper
501498
502499 def test_extract_releases_success (self ):
@@ -532,7 +529,7 @@ def test_extract_releases_success(self):
532529 mock_release2 .tarball_url = 'https://github.com/facebook/react/archive/v18.0.0-rc.0.tar.gz'
533530 mock_release2 .zipball_url = 'https://github.com/facebook/react/archive/v18.0.0-rc.0.zip'
534531
535- with patch ('github_scraper.Github' ):
532+ with patch ('skill_seekers.cli. github_scraper.Github' ):
536533 scraper = self .GitHubScraper (config )
537534 scraper .repo = Mock ()
538535 scraper .repo .get_releases .return_value = [mock_release1 , mock_release2 ]
@@ -562,7 +559,7 @@ def test_extract_releases_empty(self):
562559 'github_token' : None
563560 }
564561
565- with patch ('github_scraper.Github' ):
562+ with patch ('skill_seekers.cli. github_scraper.Github' ):
566563 scraper = self .GitHubScraper (config )
567564 scraper .repo = Mock ()
568565 scraper .repo .get_releases .return_value = []
@@ -579,7 +576,7 @@ class TestGitHubToSkillConverter(unittest.TestCase):
579576 def setUp (self ):
580577 if not PYGITHUB_AVAILABLE :
581578 self .skipTest ("PyGithub not installed" )
582- from github_scraper import GitHubToSkillConverter
579+ from skill_seekers . cli . github_scraper import GitHubToSkillConverter
583580 self .GitHubToSkillConverter = GitHubToSkillConverter
584581
585582 # Create temporary directory for test output
@@ -646,7 +643,7 @@ def test_init_loads_data(self):
646643 }
647644
648645 # Override data file path
649- with patch ('github_scraper.GitHubToSkillConverter.__init__' ) as mock_init :
646+ with patch ('skill_seekers.cli. github_scraper.GitHubToSkillConverter.__init__' ) as mock_init :
650647 mock_init .return_value = None
651648 converter = self .GitHubToSkillConverter (config )
652649 converter .data_file = str (self .data_file )
@@ -669,7 +666,7 @@ def test_build_skill_creates_directory_structure(self):
669666 }
670667
671668 # Patch the paths to use our temp directory
672- with patch ('github_scraper.GitHubToSkillConverter._load_data' ) as mock_load :
669+ with patch ('skill_seekers.cli. github_scraper.GitHubToSkillConverter._load_data' ) as mock_load :
673670 mock_load .return_value = self .mock_data
674671 converter = self .GitHubToSkillConverter (config )
675672 converter .skill_dir = str (self .output_dir / 'test_skill' )
@@ -689,7 +686,7 @@ class TestErrorHandling(unittest.TestCase):
689686 def setUp (self ):
690687 if not PYGITHUB_AVAILABLE :
691688 self .skipTest ("PyGithub not installed" )
692- from github_scraper import GitHubScraper
689+ from skill_seekers . cli . github_scraper import GitHubScraper
693690 self .GitHubScraper = GitHubScraper
694691
695692 def test_invalid_repo_name (self ):
@@ -700,7 +697,7 @@ def test_invalid_repo_name(self):
700697 'github_token' : None
701698 }
702699
703- with patch ('github_scraper.Github' ):
700+ with patch ('skill_seekers.cli. github_scraper.Github' ):
704701 scraper = self .GitHubScraper (config )
705702 scraper .repo = None
706703 scraper .github .get_repo = Mock (side_effect = GithubException (404 , 'Not found' ))
@@ -720,7 +717,7 @@ def test_rate_limit_error(self):
720717 'max_issues' : 10
721718 }
722719
723- with patch ('github_scraper.Github' ):
720+ with patch ('skill_seekers.cli. github_scraper.Github' ):
724721 scraper = self .GitHubScraper (config )
725722 scraper .repo = Mock ()
726723 scraper .repo .get_issues .side_effect = GithubException (403 , 'Rate limit exceeded' )
0 commit comments