Added Python 3.8 support. Fixes #5179

1) Upgraded passlib==1.7.1 to passlib==1.7.2
2) Replace unmaintained Flask-Security with maintained Flask-Security-Too package, which is also compatible with python 3.8
3) Other compatibility code changes.
This commit is contained in:
Aditya Toshniwal
2020-02-18 12:10:38 +05:30
committed by Akshay Joshi
parent 1964e824c8
commit 915b09255c
13 changed files with 178 additions and 168 deletions

View File

@@ -46,9 +46,9 @@ class BackupMessageTest(BaseTestGenerator):
],
cmd="/test_path/pg_dump"
),
extected_msg="Backing up the server"
expected_msg="Backing up the server"
" 'test_backup_server (localhost:5444)'",
expetced_details_cmd='/test_path/pg_dump --file '
expected_details_cmd='/test_path/pg_dump --file '
'"backup_file" --host "localhost" '
'--port "5444" --username "postgres" '
'--no-password --database "postgres"'
@@ -79,9 +79,9 @@ class BackupMessageTest(BaseTestGenerator):
],
cmd="/test_path/pg_dump"
),
extected_msg="Backing up the global objects on the server "
expected_msg="Backing up the global objects on the server "
"'test_backup_server (localhost:5444)'",
expetced_details_cmd='/test_path/pg_dump --file "backup_file" '
expected_details_cmd='/test_path/pg_dump --file "backup_file" '
'--host "localhost"'
' --port "5444" --username "postgres" '
'--no-password --database "postgres"'
@@ -112,10 +112,10 @@ class BackupMessageTest(BaseTestGenerator):
],
cmd="/test_path/pg_dump"
),
extected_msg="Backing up an object on the server "
expected_msg="Backing up an object on the server "
"'test_backup_server (localhost:5444)'"
" from database 'postgres'",
expetced_details_cmd='/test_path/pg_dump --file "backup_file" '
expected_details_cmd='/test_path/pg_dump --file "backup_file" '
'--host "localhost" '
'--port "5444" --username "postgres" '
'--no-password --database "postgres"'
@@ -139,9 +139,9 @@ class BackupMessageTest(BaseTestGenerator):
)
# Check the expected message returned
self.assertEqual(backup_obj.message, self.extected_msg)
self.assertEqual(backup_obj.message, self.expected_msg)
# Check the command
obj_details = backup_obj.details(self.class_params['cmd'],
self.class_params['args'])
self.assertIn(self.expetced_details_cmd, obj_details)
self.assertIn(self.expected_details_cmd, obj_details)

View File

@@ -9,7 +9,8 @@
import sys
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc, \
current_app
from pgadmin.tools.backup import BackupMessage, BACKUP
from pgadmin.utils.route import BaseTestGenerator
from pickle import dumps, loads
@@ -108,65 +109,67 @@ class BatchProcessTest(BaseTestGenerator):
@patch('pgadmin.tools.backup.BackupMessage.get_server_details')
@patch('pgadmin.misc.bgprocess.processes.Popen')
@patch('pgadmin.misc.bgprocess.processes.current_app')
@patch('pgadmin.misc.bgprocess.processes.db')
@patch('pgadmin.tools.backup.current_user')
@patch('pgadmin.misc.bgprocess.processes.current_user')
def runTest(self, current_user_mock, current_user, db_mock,
current_app_mock, popen_mock, get_server_details_mock):
current_user.id = 1
current_user_mock.id = 1
current_app_mock.PGADMIN_RUNTIME = False
popen_mock, get_server_details_mock):
with self.app.app_context():
current_user.id = 1
current_user_mock.id = 1
current_app.PGADMIN_RUNTIME = False
def db_session_add_mock(j):
cmd_obj = loads(j.desc)
self.assertTrue(isinstance(cmd_obj, IProcessDesc))
self.assertEqual(cmd_obj.backup_type, self.class_params['type'])
self.assertEqual(cmd_obj.bfile, self.class_params['bfile'])
self.assertEqual(cmd_obj.database, self.class_params['database'])
self.assertEqual(cmd_obj.cmd,
' --file "backup_file" '
'--host "{0}" '
'--port "{1}" '
'--username "{2}" '
'--no-password '
'--database "{3}"'.format(
self.class_params['host'],
self.class_params['port'],
self.class_params['username'],
self.class_params['database']
))
def db_session_add_mock(j):
cmd_obj = loads(j.desc)
self.assertTrue(isinstance(cmd_obj, IProcessDesc))
self.assertEqual(cmd_obj.backup_type,
self.class_params['type'])
self.assertEqual(cmd_obj.bfile, self.class_params['bfile'])
self.assertEqual(cmd_obj.database,
self.class_params['database'])
self.assertEqual(cmd_obj.cmd,
' --file "backup_file" '
'--host "{0}" '
'--port "{1}" '
'--username "{2}" '
'--no-password '
'--database "{3}"'.format(
self.class_params['host'],
self.class_params['port'],
self.class_params['username'],
self.class_params['database']
))
db_mock.session.add.side_effect = db_session_add_mock
db_mock.session.commit = MagicMock(return_value=True)
db_mock.session.add.side_effect = db_session_add_mock
db_mock.session.commit = MagicMock(return_value=True)
get_server_details_mock.return_value = \
self.class_params['name'],\
self.class_params['host'],\
self.class_params['port']
get_server_details_mock.return_value = \
self.class_params['name'], \
self.class_params['host'], \
self.class_params['port']
backup_obj = BackupMessage(
self.class_params['type'],
self.class_params['sid'],
self.class_params['bfile'],
*self.class_params['args'],
**{'database': self.class_params['database']}
)
backup_obj = BackupMessage(
self.class_params['type'],
self.class_params['sid'],
self.class_params['bfile'],
*self.class_params['args'],
**{'database': self.class_params['database']}
)
p = BatchProcess(
desc=backup_obj,
cmd=self.class_params['cmd'],
args=self.class_params['args']
)
p = BatchProcess(
desc=backup_obj,
cmd=self.class_params['cmd'],
args=self.class_params['args']
)
# Check that _create_process has been called
self.assertTrue(db_mock.session.add.called)
# Check that _create_process has been called
self.assertTrue(db_mock.session.add.called)
# Check start method
self._check_start(popen_mock, p, backup_obj)
# Check start method
self._check_start(popen_mock, p, backup_obj)
# Check list method
self._check_list(p, backup_obj)
# Check list method
self._check_list(p, backup_obj)
@patch('pgadmin.misc.bgprocess.processes.Process')
def _check_start(self, popen_mock, p, backup_obj, process_mock):