mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -06:00
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
import uuid
|
|
import config
|
|
import sys
|
|
from pgadmin.utils.route import BaseSocketTestGenerator
|
|
from regression.python_test_utils import test_utils as utils
|
|
from regression import parent_node_dict
|
|
from regression.test_setup import config_data
|
|
|
|
|
|
class PSQLStartProcessFail(BaseSocketTestGenerator):
|
|
SOCKET_NAMESPACE = '/pty'
|
|
|
|
def setUp(self):
|
|
super(PSQLStartProcessFail, self).setUp()
|
|
self.db_name = "psqltestdb_{0}".format(str(uuid.uuid4())[1:8])
|
|
self.sid = parent_node_dict["server"][-1]["server_id"]
|
|
self.did = utils.create_database(self.server, self.db_name)
|
|
self.sgid = config_data["server_group"]
|
|
config.ENABLE_PSQL = True
|
|
|
|
def runTest(self):
|
|
if sys.platform == 'win32':
|
|
self.skipTest('PSQL disabled for windows')
|
|
received = self.socket_client.get_received('/pty')
|
|
assert received[0]['name'] == 'connected'
|
|
assert received[0]['args'][0]['sid'] != ''
|
|
|
|
data = {
|
|
'sid': self.sid,
|
|
'db': 'postgres',
|
|
'pwd': self.server['db_password'],
|
|
'user': self.server['username']
|
|
}
|
|
config.ENABLE_PSQL = False
|
|
self.socket_client.emit('start_process', data, namespace='/pty')
|
|
received = self.socket_client.get_received('/pty')
|
|
|
|
assert received[0]['name'] == 'conn_not_allow'
|
|
|
|
self.socket_client.disconnect(namespace='/pty')
|
|
self.assertFalse(self.socket_client.is_connected('/pty'))
|
|
|
|
def tearDown(self):
|
|
connection = utils.get_db_connection(self.server['db'],
|
|
self.server['username'],
|
|
self.server['db_password'],
|
|
self.server['host'],
|
|
self.server['port'])
|
|
utils.drop_database(connection, self.db_name)
|
|
connection.close()
|