Refactored Tests
This commit is contained in:
		
							parent
							
								
									86cd1666c0
								
							
						
					
					
						commit
						a9270f67fd
					
				|  | @ -14,7 +14,9 @@ class YouTubeTranscriptCli(): | |||
|     def run(self): | ||||
|         parsed_args = self._parse_args() | ||||
| 
 | ||||
|         proxies = {"http": parsed_args.http_proxy, "https": parsed_args.https_proxy} | ||||
|         proxies = None | ||||
|         if parsed_args.http_proxy != '' or parsed_args.https_proxy != '': | ||||
|             proxies = {"http": parsed_args.http_proxy, "https": parsed_args.https_proxy} | ||||
| 
 | ||||
|         transcripts, _ = YouTubeTranscriptApi.get_transcripts( | ||||
|             parsed_args.video_ids, | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import os | |||
| 
 | ||||
| import httpretty | ||||
| 
 | ||||
| from youtube_transcript_api._api import YouTubeTranscriptApi | ||||
| from youtube_transcript_api._api import YouTubeTranscriptApi, _TranscriptFetcher | ||||
| 
 | ||||
| 
 | ||||
| def load_asset(filename): | ||||
|  | @ -103,8 +103,9 @@ class TestYouTubeTranscriptApi(TestCase): | |||
|         YouTubeTranscriptApi.get_transcript.assert_any_call(video_id_2, None, None) | ||||
| 
 | ||||
|     def test_get_transcript__with_proxies(self): | ||||
|         proxies = {'http': '', 'https:': ''} | ||||
|         transcript = YouTubeTranscriptApi.get_transcript( | ||||
|             'GJLlxj_dtq8', proxies={'http': '', 'https:': ''} | ||||
|             'GJLlxj_dtq8', proxies=proxies | ||||
|         ) | ||||
| 
 | ||||
|         self.assertEqual( | ||||
|  | @ -115,3 +116,6 @@ class TestYouTubeTranscriptApi(TestCase): | |||
|                 {'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239} | ||||
|             ] | ||||
|         ) | ||||
|         YouTubeTranscriptApi.get_transcript = MagicMock() | ||||
|         YouTubeTranscriptApi.get_transcripts(['GJLlxj_dtq8'], proxies=proxies) | ||||
|         YouTubeTranscriptApi.get_transcript.assert_any_call('GJLlxj_dtq8', None, proxies) | ||||
|  |  | |||
|  | @ -39,6 +39,7 @@ class TestYouTubeTranscriptCli(TestCase): | |||
|         self.assertEqual(parsed_args.json, True) | ||||
|         self.assertEqual(parsed_args.languages, ['de', 'en']) | ||||
|         self.assertEqual(parsed_args.http_proxy, 'http://user:pass@domain:port') | ||||
|         self.assertEqual(parsed_args.https_proxy, '') | ||||
| 
 | ||||
|         parsed_args = YouTubeTranscriptCli( | ||||
|             'v1 v2 --languages de en --json --https-proxy https://user:pass@domain:port'.split() | ||||
|  | @ -47,6 +48,7 @@ class TestYouTubeTranscriptCli(TestCase): | |||
|         self.assertEqual(parsed_args.json, True) | ||||
|         self.assertEqual(parsed_args.languages, ['de', 'en']) | ||||
|         self.assertEqual(parsed_args.https_proxy, 'https://user:pass@domain:port') | ||||
|         self.assertEqual(parsed_args.http_proxy, '') | ||||
| 
 | ||||
|     def test_argument_parsing__only_video_ids(self): | ||||
|         parsed_args = YouTubeTranscriptCli('v1 v2'.split())._parse_args() | ||||
|  | @ -94,7 +96,7 @@ class TestYouTubeTranscriptCli(TestCase): | |||
|             ['v1', 'v2'], | ||||
|             languages=['de', 'en'], | ||||
|             continue_after_error=True, | ||||
|             proxies={"http": "", "https": ""} | ||||
|             proxies=None | ||||
|         ) | ||||
| 
 | ||||
|     def test_run__json_output(self): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue