def testNonRootWrongUserLaunch(self, mock_pwnam, mock_listdir): mock_listdir.return_value = ['X123'] mock_pwnam.return_value = mock.Mock(pw_dir='/HOME', pw_uid=100, pw_gid=100) with self.assertRaisesRegexp(ValueError, 'Cannot run as non-root.*'): web_launcher.launch('url')
def testNoXauthLaunch(self, mock_pwnam, mock_listdir): mock_listdir.return_value = ['X123'] mock_pwnam.return_value = mock.Mock(pw_dir='/HOME', pw_uid=100, pw_gid=100) with self.assertRaisesRegexp(ValueError, '.*Xauthority does not exist'): web_launcher.launch('url')
def testRootSuccess(self, mock_pwnam, mock_listdir): mock_listdir.return_value = ['X123'] mock_pwnam.return_value = mock.Mock(pw_dir='/HOME', pw_uid=100, pw_gid=100) web_launcher.launch('url')
def testNonRootCorrectUserLaunch(self, mock_pwnam, mock_listdir): mock_listdir.return_value = ['X123'] mock_pwnam.return_value = mock.Mock(pw_dir='/HOME', pw_uid=100, pw_gid=100) web_launcher.launch('url')
def testNoXLaunch(self, mock_listdir): mock_listdir.return_value = [] with self.assertRaisesRegexp(ValueError, 'No running X11 display.'): web_launcher.launch('url')
def testNormalLaunch(self, mock_open): web_launcher.launch('url') mock_open.assert_called_once_with('url')