Enhancements to the regression test suite.

Navnath Gadakh and Priyanka Shendge
This commit is contained in:
Dave Page
2016-07-18 14:50:21 +01:00
parent c7d25c33f2
commit f17c2e3b84
25 changed files with 1293 additions and 308 deletions

View File

@@ -0,0 +1,15 @@
# ##########################################################################
#
# #pgAdmin 4 - PostgreSQL Tools
#
# #Copyright (C) 2013 - 2016, The pgAdmin Development Team
# #This software is released under the PostgreSQL Licence
#
# ##########################################################################
from pgadmin.utils.route import BaseTestGenerator
class DatabaseCreateTestCase(BaseTestGenerator):
def runTest(self):
return

View File

@@ -0,0 +1,74 @@
# #################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
# ##################################################################
import json
import uuid
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import advanced_config_data
class DatabaseAddTestCase(BaseTestGenerator):
"""
This class will check server group node present on the object browser's
tree node by response code.
"""
scenarios = [
# Fetching default URL for database node.
('Check Databases Node URL', dict(url='/browser/database/obj/'))
]
def setUp(self):
"""
This function perform the two tasks
1. Login to test client
2. Add the test server
:return: None
"""
utils.login_tester_account(self.tester)
# Add the server
utils.add_server(self.tester)
def runTest(self):
""" This function will add database under 1st server of tree node. """
server_connect_response, server_group, server_ids = \
utils.connect_server(self.tester)
# Store db id. Which is use to delete in tearDown()
self.db_id = ''
for server_connect, server_id in zip(server_connect_response,
server_ids):
if server_connect['data']['connected']:
data = utils.get_db_data(server_connect)
db_response = self.tester.post(self.url + str(server_group) +
"/" + server_id + "/",
data=json.dumps(data),
content_type='html/json')
self.assertTrue(db_response.status_code, 200)
response_data = json.loads(db_response.data.decode('utf-8'))
utils.write_db_parent_id(response_data)
self.db_id = response_data['node']['_id']
def tearDown(self):
"""
This function deletes the 'parent_id.pkl' file which is created in
setup() function. Also this function logout the test client
:return: None
"""
utils.delete_database(self.tester, self.db_id)
utils.delete_server(self.tester)
utils.delete_parent_id_file()
utils.logout_tester_account(self.tester)

View File

@@ -0,0 +1,73 @@
# #################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
# ##################################################################
import json
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data
from regression.test_utils import get_ids, test_getnodes
class DatabaseDeleteTestCase(BaseTestGenerator):
""" This class will delete the database under last added server. """
scenarios = [
# Fetching default URL for database node.
('Check Databases Node URL', dict(url='/browser/database/obj/'))
]
def setUp(self):
"""
This function perform the three tasks
1. Login to test client
2. Add the test server
3. Connect to server
:return: None
"""
utils.login_tester_account(self.tester)
# Firstly, add the server
utils.add_server(self.tester)
# Secondly, connect to server/database
utils.connect_server(self.tester)
def runTest(self):
""" This function will delete the database."""
srv_grp = config_data['test_server_group']
all_id = get_ids()
server_ids = all_id["sid"]
# TODO: Need to modify the code , to delete the databases for all
# TODO: servers. Currently it delete only one database.
db_id = all_id["did"][0]
db_con = test_getnodes(self.tester)
if len(db_con) == 0:
raise Exception("No database(s) to delete!!!")
for server_id in server_ids:
response = self.tester.delete(self.url + str(srv_grp) + '/' +
str(server_id) + '/' + str(db_id),
follow_redirects=True)
response_data = json.loads(response.data.decode('utf-8'))
self.assertTrue(response_data['success'], 1)
def tearDown(self):
"""
This function deletes the 'parent_id.pkl' file which is created in
setup() function. Also this function logout the test client
:return: None
"""
utils.delete_server(self.tester)
utils.delete_parent_id_file()
utils.logout_tester_account(self.tester)

View File

@@ -0,0 +1,72 @@
# #################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
# ##################################################################
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data
from regression.test_utils import get_ids, test_getnodes
class DatabasesGetTestCase(BaseTestGenerator):
"""
This class will fetch database added under last added server.
"""
scenarios = [
# Fetching default URL for database node.
('Check Databases Node URL', dict(url='/browser/database/obj/'))
]
def setUp(self):
"""
This function perform the three tasks
1. Login to test client
2. Add the test server
3. Connect to server
:return: None
"""
utils.login_tester_account(self.tester)
# Firstly, add the server
utils.add_server(self.tester)
# Secondly, connect to server/database
utils.connect_server(self.tester)
def runTest(self):
""" This function will fetch added database. """
all_id = get_ids()
server_ids = all_id["sid"]
# TODO: Code is remaining to get all databases of all servers
self.db_id = all_id["did"][0]
srv_grp = config_data['test_server_group']
for server_id in server_ids:
db_con = test_getnodes(self.tester)
if db_con["info"] == "Database connected.":
response = self.tester.get(self.url + str(srv_grp) + '/' +
str(server_id) + '/' + str(
self.db_id),
follow_redirects=True)
self.assertEquals(response.status_code, 200)
def tearDown(self):
"""
This function deletes the 'parent_id.pkl' file which is created in
setup() function. Also this function logout the test client
:return: None
"""
utils.delete_database(self.tester, self.db_id)
utils.delete_server(self.tester)
utils.delete_parent_id_file()
utils.logout_tester_account(self.tester)

View File

@@ -0,0 +1,79 @@
# #################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
# ##################################################################
import json
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data, advanced_config_data
from regression.test_utils import get_ids, test_getnodes
class DatabasesUpdateTestCase(BaseTestGenerator):
"""
This class will update the database under last added server.
"""
scenarios = [
# Fetching default URL for database node.
('Check Databases Node', dict(url='/browser/database/obj/'))
]
def setUp(self):
"""
This function perform the three tasks
1. Login to test client
2. Add the test server
3. Connect to server
:return: None
"""
utils.login_tester_account(self.tester)
# Firstly, add the server
utils.add_server(self.tester)
# Secondly, connect to server/database
utils.connect_server(self.tester)
def runTest(self):
""" This function will update the comments field of database."""
srv_grp = config_data['test_server_group']
all_id = get_ids()
server_ids = all_id["sid"]
# TODO: Need to modify the code , to delete the databases for all
# TODO: servers. Currently it delete only one database.
db_id = all_id["did"][0]
test_getnodes(self.tester)
data = {
"comments": advanced_config_data["test_db_update_data"][0]
["test_comment"],
"id": db_id
}
for server_id in server_ids:
put_response = self.tester.put(self.url + str(srv_grp) + '/' +
str(server_id) + '/' + str(db_id),
data=json.dumps(data),
follow_redirects=True)
self.assertEquals(put_response.status_code, 200)
def tearDown(self):
"""
This function deletes the 'parent_id.pkl' file which is created in
setup() function. Also this function logout the test client
:return: None
"""
utils.delete_server(self.tester)
utils.delete_parent_id_file()
utils.logout_tester_account(self.tester)