Exemplo n.º 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, [])
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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] ")])
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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")])
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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")])
Exemplo n.º 11
0
 def test_check_file_output(self):
     streamlink_cli.main.console = Mock()
     self.assertIsInstance(check_file_output("test", False), FileOutput)
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 14
0
 def test_check_file_output(self):
     output = check_file_output("foo", False)
     self.assertIsInstance(output, FileOutput)
     self.assertEqual(output.filename, "foo")
Exemplo n.º 15
0
 def test_check_file_output(self):
     streamlink_cli.main.console = Mock()
     self.assertIsInstance(check_file_output("test", False), FileOutput)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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")