Repository: jdepoix/youtube-transcript-api
File: youtube_transcript_api/test/test_cli.py (Python)

Code before:
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, ['de', 'en'])

        parsed_args = YouTubeTranscriptCli(
            'v1 v2 --languages de en --json --http-proxy http://user:pass@domain:port --https-proxy https://user:pass@domain:port'.split()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        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, 'https://user:pass@domain:port')

        parsed_args = YouTubeTranscriptCli(
            'v1 v2 --languages de en --json --http-proxy http://user:pass@domain:port'.split()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, ['de', 'en'])
        self.assertEqual(parsed_args.http_proxy, 'http://user:pass@domain:port')

        parsed_args = YouTubeTranscriptCli(
            'v1 v2 --languages de en --json --https-proxy https://user:pass@domain:port'.split()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, ['de', 'en'])
        self.assertEqual(parsed_args.https_proxy, 'https://user:pass@domain:port')

    def test_argument_parsing__only_video_ids(self):
        parsed_args = YouTubeTranscriptCli('v1 v2'.split())._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, False)
        self.assertEqual(parsed_args.languages, [])

    def test_argument_parsing__fail_without_video_ids(self):
        with self.assertRaises(SystemExit):
            YouTubeTranscriptCli('--json'.split())._parse_args()

    def test_argument_parsing__json(self):
        parsed_args = YouTubeTranscriptCli('v1 v2 --json'.split())._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, [])

        parsed_args = YouTubeTranscriptCli('--json v1 v2'.split())._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, [])

    def test_argument_parsing__languages(self):

Review comment (suggestion):
also make sure that the arguments which are not explicitly set default to the expected value (`https_proxy`)

Code after:
        self.assertEqual(parsed_args.http_proxy, '')
        self.assertEqual(parsed_args.https_proxy, '')

        parsed_args = YouTubeTranscriptCli(' --json v1 v2 --languages de en'.split())._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)
        self.assertEqual(parsed_args.languages, ['de', 'en'])
        self.assertEqual(parsed_args.http_proxy, '')
        self.assertEqual(parsed_args.https_proxy, '')

        parsed_args = YouTubeTranscriptCli(
            'v1 v2 --languages de en --json --http-proxy http://user:pass@domain:port --https-proxy https://user:pass@domain:port'.split()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        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, 'https://user:pass@domain:port')

        parsed_args = YouTubeTranscriptCli(
            'v1 v2 --languages de en --json --http-proxy http://user:pass@domain:port'.split()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        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()
        )._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        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()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, False)
        self.assertEqual(parsed_args.languages, [])

    def test_argument_parsing__fail_without_video_ids(self):
        with self.assertRaises(SystemExit):
            YouTubeTranscriptCli('--json'.split())._parse_args()

    def test_argument_parsing__json(self):
        parsed_args = YouTubeTranscriptCli('v1 v2 --json'.split())._parse_args()
        self.assertEqual(parsed_args.video_ids, ['v1', 'v2'])
        self.assertEqual(parsed_args.json, True)