Exemplo n.º 1
0
 def test_system_default_application(self, caplog, config_stub,
                                     openurl_mock):
     utils.open_file('/foo/bar')
     result = caplog.messages[0]
     assert re.fullmatch(
         r"Opening /foo/bar with the system application", result)
     openurl_mock.assert_called_with(QUrl('file:///foo/bar'))
Exemplo n.º 2
0
 def test_cmdline_with_argument(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass {{}} raboof'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.messages[0]
     assert re.fullmatch(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*'raboof'\]", result)
Exemplo n.º 3
0
 def test_cmdline_without_argument(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.messages[0]
     assert re.fullmatch(
         r'Opening /foo/bar with \[.*python.*/foo/bar.*\]', result)
Exemplo n.º 4
0
 def test_cmdline_with_argument(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass {{}} raboof'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.records[0].message
     assert re.fullmatch(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*'raboof'\]", result)
Exemplo n.º 5
0
 def test_cmdline_without_argument(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.records[0].message
     assert re.match(
         r'Opening /foo/bar with \[.*python.*/foo/bar.*\]', result)
Exemplo n.º 6
0
 def test_cmdline_with_argument(self, caplog, config_stub):
     config_stub.data = {'general': {'default-open-dispatcher': ''}}
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass {{}} raboof'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.records[0].message
     assert re.match(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*'raboof'\]", result)
Exemplo n.º 7
0
 def test_system_default_application(self, caplog, config_stub, mocker):
     m = mocker.patch('PyQt5.QtGui.QDesktopServices.openUrl', spec={},
                      new_callable=mocker.Mock)
     utils.open_file('/foo/bar')
     result = caplog.messages[0]
     assert re.fullmatch(
         r"Opening /foo/bar with the system application", result)
     m.assert_called_with(QUrl('file:///foo/bar'))
Exemplo n.º 8
0
 def test_setting_override(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     config_stub.val.downloads.open_dispatcher = cmdline
     utils.open_file('/foo/bar')
     result = caplog.messages[1]
     assert re.fullmatch(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*\]", result)
Exemplo n.º 9
0
 def test_setting_override(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     config_stub.data = {'general': {'default-open-dispatcher': cmdline}}
     utils.open_file('/foo/bar')
     result = caplog.records[0].message
     assert re.match(r"Opening /foo/bar with \[.*python.*/foo/bar.*\]",
                     result)
Exemplo n.º 10
0
 def test_system_default_application(self, caplog, config_stub, mocker):
     m = mocker.patch('PyQt5.QtGui.QDesktopServices.openUrl', spec={},
                      new_callable=mocker.Mock)
     utils.open_file('/foo/bar')
     result = caplog.records[0].message
     assert re.fullmatch(
         r"Opening /foo/bar with the system application", result)
     m.assert_called_with(QUrl('file:///foo/bar'))
Exemplo n.º 11
0
 def test_setting_override(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     config_stub.val.downloads.open_dispatcher = cmdline
     utils.open_file('/foo/bar')
     result = caplog.records[1].message
     assert re.fullmatch(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*\]", result)
Exemplo n.º 12
0
 def test_setting_override(self, caplog, config_stub):
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass'.format(executable)
     config_stub.data = {'general': {'default-open-dispatcher': cmdline}}
     utils.open_file('/foo/bar')
     result = caplog.records[0].message
     assert re.match(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*\]", result)
Exemplo n.º 13
0
 def test_cmdline_with_argument(self, caplog, config_stub):
     config_stub.data = {'general': {'default-open-dispatcher': ''}}
     executable = shlex.quote(sys.executable)
     cmdline = '{} -c pass {{}} raboof'.format(executable)
     utils.open_file('/foo/bar', cmdline)
     result = caplog.records[0].message
     assert re.match(
         r"Opening /foo/bar with \[.*python.*/foo/bar.*'raboof'\]", result)
Exemplo n.º 14
0
 def test_system_default_application(self, caplog, config_stub, mocker):
     config_stub.data = {'general': {'default-open-dispatcher': ''}}
     m = mocker.patch('PyQt5.QtGui.QDesktopServices.openUrl', spec={},
                      new_callable=mocker.Mock)
     utils.open_file('/foo/bar')
     result = caplog.records[0].message
     assert re.match(
         r"Opening /foo/bar with the system application", result)
     m.assert_called_with(QUrl('file:///foo/bar'))
Exemplo n.º 15
0
    def test_setting_override_sandboxed(self, fake_flatpak, openurl_mock,
                                        caplog, config_stub):
        config_stub.val.downloads.open_dispatcher = 'test'

        with caplog.at_level(logging.WARNING):
            utils.open_file('/foo/bar')

        assert caplog.messages[1] == ('Ignoring download dispatcher from '
                                      'config in sandbox environment')
        openurl_mock.assert_called_with(QUrl('file:///foo/bar'))
Exemplo n.º 16
0
 def test_cmdline_sandboxed(self, fake_flatpak,
                            config_stub, message_mock, caplog):
     with caplog.at_level(logging.ERROR):
         utils.open_file('/foo/bar', 'custom_cmd')
     msg = message_mock.getmsg(usertypes.MessageLevel.error)
     assert msg.text == 'Cannot spawn download dispatcher from sandbox'
Exemplo n.º 17
0
 def test_system_default_sandboxed(self, config_stub, openurl_mock,
                                   fake_flatpak):
     utils.open_file('/foo/bar')
     openurl_mock.assert_called_with(QUrl('file:///foo/bar'))