Example #1
0
 def test_check_file_output_exists_notty(self, mock_sys: Mock,
                                         mock_console: Mock):
     mock_sys.stdin.isatty.return_value = False
     mock_sys.exit.side_effect = SystemExit
     path = self.mock_path("foo", is_file=True)
     with self.assertRaises(SystemExit):
         check_file_output(path, False)
     self.assertEqual(mock_console.ask.call_args_list, [])
Example #2
0
 def test_check_file_output_exists_no(self, sys_exit):
     tmpfile = tempfile.NamedTemporaryFile()
     try:
         streamlink_cli.main.console = console = Mock()
         console.ask.return_value = "n"
         self.assertTrue(os.path.exists(tmpfile.name))
         check_file_output(tmpfile.name, False)
         sys_exit.assert_called_with()
     finally:
         tmpfile.close()
Example #3
0
 def test_check_file_output_exists_no(self, sys_exit):
     tmpfile = tempfile.NamedTemporaryFile()
     try:
         streamlink_cli.main.console = console = Mock()
         console.ask.return_value = "n"
         self.assertTrue(os.path.exists(tmpfile.name))
         check_file_output(tmpfile.name, False)
         sys_exit.assert_called_with()
     finally:
         tmpfile.close()
Example #4
0
 def test_check_file_output_exists_ask_no(self, mock_sys: Mock,
                                          mock_console: Mock):
     mock_sys.stdin.isatty.return_value = True
     mock_sys.exit.side_effect = SystemExit
     mock_console.ask = Mock(return_value="N")
     path = self.mock_path("foo", is_file=True)
     with self.assertRaises(SystemExit):
         check_file_output(path, False)
     self.assertEqual(
         mock_console.ask.call_args_list,
         [call("File foo already exists! Overwrite it? [y/N] ")])
Example #5
0
 def test_check_file_output_exists_force(self):
     tmpfile = tempfile.NamedTemporaryFile()
     try:
         streamlink_cli.main.console = Mock()
         self.assertTrue(os.path.exists(tmpfile.name))
         self.assertIsInstance(check_file_output(tmpfile.name, True), FileOutput)
     finally:
         tmpfile.close()
Example #6
0
 def test_check_file_output_exists_force(self):
     tmpfile = tempfile.NamedTemporaryFile()
     try:
         streamlink_cli.main.console = console = Mock()
         self.assertTrue(os.path.exists(tmpfile.name))
         self.assertIsInstance(check_file_output(tmpfile.name, True), FileOutput)
     finally:
         tmpfile.close()
Example #7
0
 def test_check_file_output(self, mock_log: Mock):
     path = self.mock_path("foo", is_file=False, resolve="/path/to/foo")
     output = check_file_output(path, False)
     self.assertIsInstance(output, FileOutput)
     self.assertIs(output.filename, path)
     self.assertEqual(mock_log.info.call_args_list,
                      [call("Writing output to\n/path/to/foo")])
     self.assertEqual(mock_log.debug.call_args_list,
                      [call("Checking file output")])
Example #8
0
 def test_check_file_output_exists(self):
     tmpfile = tempfile.NamedTemporaryFile()
     try:
         streamlink_cli.main.console = console = Mock()
         console.ask.return_value = "y"
         self.assertTrue(os.path.exists(tmpfile.name))
         self.assertIsInstance(check_file_output(tmpfile.name, False), FileOutput)
     finally:
         tmpfile.close()
Example #9
0
 def test_check_file_output_exists_ask_yes(self, mock_sys: Mock,
                                           mock_console: Mock):
     mock_sys.stdin.isatty.return_value = True
     mock_console.ask = Mock(return_value="y")
     path = self.mock_path("foo", is_file=True)
     output = check_file_output(path, False)
     self.assertEqual(
         mock_console.ask.call_args_list,
         [call("File foo already exists! Overwrite it? [y/N] ")])
     self.assertIsInstance(output, FileOutput)
     self.assertIs(output.filename, path)
Example #10
0
 def test_check_file_output(self, mock_log):
     streamlink_cli.main.console = Mock()
     self.assertIsInstance(check_file_output("foo", False), FileOutput)
     self.assertEqual(mock_log.debug.call_args_list,
                      [call("Checking file output")])
Example #11
0
 def test_check_file_output(self):
     streamlink_cli.main.console = Mock()
     self.assertIsInstance(check_file_output("test", False), FileOutput)
Example #12
0
 def test_check_file_output_exists_force(self):
     output = check_file_output("foo", True)
     self.assertIsInstance(output, FileOutput)
     self.assertEqual(output.filename, "foo")
Example #13
0
 def test_check_file_output_exists_force(self):
     path = self.mock_path("foo", is_file=True)
     output = check_file_output(path, True)
     self.assertIsInstance(output, FileOutput)
     self.assertIs(output.filename, path)
Example #14
0
 def test_check_file_output(self):
     output = check_file_output("foo", False)
     self.assertIsInstance(output, FileOutput)
     self.assertEqual(output.filename, "foo")
Example #15
0
 def test_check_file_output(self):
     streamlink_cli.main.console = Mock()
     self.assertIsInstance(check_file_output("test", False), FileOutput)
Example #16
0
 def test_check_file_output(self):
     path = self.mock_path("foo", is_file=False)
     output = check_file_output(path, False)
     self.assertIsInstance(output, FileOutput)
     self.assertIs(output.filename, path)
Example #17
0
 def test_check_file_output_exists_notty(self, mock_sys: Mock):
     mock_sys.stdin.isatty.return_value = False
     mock_sys.exit.side_effect = SystemExit
     with self.assertRaises(SystemExit):
         check_file_output("foo", False)
Example #18
0
 def test_check_file_output_exists_ask_yes(self, mock_sys: Mock):
     mock_sys.stdin.isatty.return_value = True
     output = check_file_output("foo", False)
     self.assertIsInstance(output, FileOutput)
     self.assertEqual(output.filename, "foo")