def runshell(self): from django.db import connection conn_string = connection._connect_string(settings) args = [self.executable_name, "-L", conn_string] if os.name == 'nt': sys.exit(os.system(" ".join(args))) else: os.execvp(self.executable_name, args)
def test_with_rlwrap(self): run_args, run_kwargs = self._run_dbshell(rlwrap=True) self.assertEqual( run_args, ('/usr/bin/rlwrap', 'sqlplus', '-L', connection._connect_string()), ) self.assertEqual( run_kwargs, {'check': True}, )
def test_password_with_at_sign(self): old_password = connection.settings_dict['PASSWORD'] connection.settings_dict['PASSWORD'] = '******' try: self.assertIn('/"p@ssword"@', connection._connect_string()) with self.assertRaises(DatabaseError) as context: connection.cursor() # Database exception: "ORA-01017: invalid username/password" is # expected. self.assertIn('ORA-01017', context.exception.args[0].message) finally: connection.settings_dict['PASSWORD'] = old_password
def test_with_input(self): run_args, run_kwargs = self._run_dbshell(rlwrap=True, input=b'testdata') self.assertEqual( run_args, ('/usr/bin/rlwrap', 'sqlplus', '-L', connection._connect_string()), ) self.assertEqual( run_kwargs, { 'check': True, 'input': b'testdata' }, )
def runshell(self): from django.db import connection conn_string = connection._connect_string(settings) args = [self.executable_name, "-L", conn_string] os.execvp(self.executable_name, args)
def test_parameters(self): self.assertEqual( self._run_dbshell(parameters=['-HELP']), ['sqlplus', '-L', connection._connect_string(), '-HELP'], )
def test_with_rlwrap(self): self.assertEqual( self._run_dbshell(rlwrap=True), ['/usr/bin/rlwrap', 'sqlplus', '-L', connection._connect_string()], )
def test_without_rlwrap(self): self.assertEqual( self._run_dbshell(rlwrap=False), ['sqlplus', '-L', connection._connect_string()], )