Improve code coverage and API test cases for the LANGUAGE module. Fixes #5050.
parent
430e9ae994
commit
30b4b5b349
|
@ -15,6 +15,7 @@ Housekeeping
|
|||
************
|
||||
|
||||
| `Issue #5049 <https://redmine.postgresql.org/issues/5049>`_ - Improve code coverage and API test cases for the CAST module.
|
||||
| `Issue #5050 <https://redmine.postgresql.org/issues/5050>`_ - Improve code coverage and API test cases for the LANGUAGE module.
|
||||
| `Issue #5071 <https://redmine.postgresql.org/issues/5071>`_ - Improve the test framework to run for multiple classes defined in a single file.
|
||||
| `Issue #5072 <https://redmine.postgresql.org/issues/5072>`_ - Updated wcDocker package which includes aria-label accessibility improvements.
|
||||
| `Issue #5096 <https://redmine.postgresql.org/issues/5096>`_ - Replace node-sass with sass for SCSS compilation.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"cast_create": [
|
||||
{
|
||||
"name": "TC_01 - Create cast: With valid source & target type of implicit_type.",
|
||||
"name": "Create cast: With valid source & target type of implicit_type.",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Create cast: With valid source & target type of explict_type.",
|
||||
"name": "Create cast: With valid source & target type of explict_type.",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -39,7 +39,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Create cast: With invalid source type.",
|
||||
"name": "Create cast: With invalid source type.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -58,7 +58,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_04 - Create cast: With insufficient parameters missing target type.",
|
||||
"name": "Create cast: With insufficient parameters missing target type.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -76,7 +76,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_05 - Create cast: With valid data while server down",
|
||||
"name": "Create cast: With valid data while server down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -98,7 +98,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_06 - Create cast: With valid data while exception.",
|
||||
"name": "Create cast: With valid data while exception.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -122,7 +122,7 @@
|
|||
],
|
||||
"cast_create_get_functions": [
|
||||
{
|
||||
"name": "TC_01 - From create cast dialogue, get available cast functions for valid source & target type",
|
||||
"name": "From create cast dialogue, get available cast functions for valid source & target type",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -141,7 +141,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - From create cast dialogue, get available cast functions when server is down",
|
||||
"name": "From create cast dialogue, get available cast functions when server is down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {
|
||||
|
@ -167,7 +167,7 @@
|
|||
|
||||
"cast_create_get_type": [
|
||||
{
|
||||
"name": "TC_01 - From create cast dialogue get available cast types",
|
||||
"name": "From create cast dialogue get available cast types",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {},
|
||||
"test_data": {},
|
||||
|
@ -180,7 +180,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - From create cast dialogue get available cast types while server is down",
|
||||
"name": "From create cast dialogue get available cast types while server is down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {},
|
||||
"test_data": {},
|
||||
|
@ -199,7 +199,7 @@
|
|||
|
||||
"cast_delete": [
|
||||
{
|
||||
"name": "TC_01 - Delete existing cast using cast id",
|
||||
"name": "Delete existing cast using cast id",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "EXPLICIT",
|
||||
|
@ -218,7 +218,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Delete non-existing cast using cast id",
|
||||
"name": "Delete non-existing cast using cast id",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -237,7 +237,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Delete existing cast using cast id while server down",
|
||||
"name": "Delete existing cast using cast id while server down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -261,7 +261,7 @@
|
|||
],
|
||||
"cast_delete_multiple": [
|
||||
{
|
||||
"name": "TC_01 - Delete multiple existing casts using cast ids",
|
||||
"name": "Delete multiple existing casts using cast ids",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "EXPLICIT",
|
||||
|
@ -280,7 +280,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Delete multiple existing casts using cast ids while server down",
|
||||
"name": "Delete multiple existing casts using cast ids while server down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -303,7 +303,7 @@
|
|||
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Delete multiple existing casts using cast ids while exception",
|
||||
"name": "Delete multiple existing casts using cast ids while exception",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -329,7 +329,7 @@
|
|||
|
||||
"cast_get": [
|
||||
{
|
||||
"name": "TC_01 - Get cast details: With existing cast id.",
|
||||
"name": "Get cast details: With existing cast id.",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -349,7 +349,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Get casts list: With existing db id.",
|
||||
"name": "Get casts list: With existing db id.",
|
||||
"is_positive_test": true,
|
||||
|
||||
"inventory_data": {
|
||||
|
@ -370,7 +370,7 @@
|
|||
"is_list": true
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Get cast details: With non existing db id",
|
||||
"name": "Get cast details: With non existing db id",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -390,7 +390,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_04 - Get cast details: With existing cast id while server is down.",
|
||||
"name": "Get cast details: With existing cast id while server is down.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -413,7 +413,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_05 - Get casts list: With existing db id while server is down.",
|
||||
"name": "Get casts list: With existing db id while server is down.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -439,7 +439,7 @@
|
|||
|
||||
"cast_get_dependencies_dependants": [
|
||||
{
|
||||
"name": "TC_01 - Get cast dependents with existing cast id",
|
||||
"name": "Get cast dependents with existing cast id",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {"castcontext": "IMPLICIT",
|
||||
"encoding": "UTF8",
|
||||
|
@ -457,7 +457,7 @@
|
|||
"is_dependant": true
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Get cast dependencies with existing cast id",
|
||||
"name": "Get cast dependencies with existing cast id",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -480,7 +480,7 @@
|
|||
|
||||
"cast_get_node": [
|
||||
{
|
||||
"name": "TC_01 - Get cast node details: With existing cast id.",
|
||||
"name": "Get cast node details: With existing cast id.",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -500,7 +500,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Get casts nodes list: With existing db id.",
|
||||
"name": "Get casts nodes list: With existing db id.",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -520,7 +520,7 @@
|
|||
"is_list": true
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Get cast node details: With non existing db id",
|
||||
"name": "Get cast node details: With non existing db id",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -540,7 +540,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_04 - Get cast node details: With existing cast id while server is down.",
|
||||
"name": "Get cast node details: With existing cast id while server is down.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -563,7 +563,7 @@
|
|||
"is_list": false
|
||||
},
|
||||
{
|
||||
"name": "TC_05 - Get casts list: With existing db id while server is down.",
|
||||
"name": "Get casts list: With existing db id while server is down.",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -589,7 +589,7 @@
|
|||
|
||||
"cast_get_sql": [
|
||||
{
|
||||
"name": "TC_01 - Get cast sql for existing cast id",
|
||||
"name": "Get cast sql for existing cast id",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -608,7 +608,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Get cast sql for non-existing cast id",
|
||||
"name": "Get cast sql for non-existing cast id",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -627,7 +627,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Get cast sql for existing cast id while server is down",
|
||||
"name": "Get cast sql for existing cast id while server is down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -649,7 +649,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_04 - Get cast sql for existing cast id while exception",
|
||||
"name": "Get cast sql for existing cast id while exception",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -675,7 +675,7 @@
|
|||
|
||||
"cast_put": [
|
||||
{
|
||||
"name": "TC_01 - Update existing cast with valid parameter Value ",
|
||||
"name": "Update existing cast with valid parameter Value ",
|
||||
"is_positive_test": true,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -694,7 +694,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_02 - Update existing cast with invalid parameter value ",
|
||||
"name": "Update existing cast with invalid parameter value ",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -715,7 +715,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_03 - Update existing cast with valid parameter value while server is down",
|
||||
"name": "Update existing cast with valid parameter value while server is down",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
@ -737,7 +737,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "TC_04 - Update non-existing cast with valid parameter value",
|
||||
"name": "Update non-existing cast with valid parameter value",
|
||||
"is_positive_test": false,
|
||||
"inventory_data": {
|
||||
"castcontext": "IMPLICIT",
|
||||
|
|
|
@ -27,7 +27,7 @@ class CastsCreateTestCase(BaseTestGenerator):
|
|||
url = '/browser/cast/obj/'
|
||||
|
||||
# Generates scenarios from cast_test_data.json file
|
||||
scenarios = cast_utils.generate_scenarios("cast_create")
|
||||
scenarios = utils.generate_scenarios("cast_create", cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will get data required to create cast."""
|
||||
|
|
|
@ -26,7 +26,8 @@ else:
|
|||
class CastsCreateGetFunctionsTestCase(BaseTestGenerator):
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_create_get_functions")
|
||||
scenarios = utils.generate_scenarios("cast_create_get_functions",
|
||||
cast_utils.test_cases)
|
||||
|
||||
def runTest(self):
|
||||
""" This function will add cast under test database. """
|
||||
|
|
|
@ -26,7 +26,8 @@ else:
|
|||
class CastsCreateGettypeTestCase(BaseTestGenerator):
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_create_get_type")
|
||||
scenarios = utils.generate_scenarios("cast_create_get_type",
|
||||
cast_utils.test_cases)
|
||||
|
||||
def runTest(self):
|
||||
""" This function will add cast under test database. """
|
||||
|
|
|
@ -28,7 +28,8 @@ class CastsDeleteTestCase(BaseTestGenerator):
|
|||
url = '/browser/cast/obj/'
|
||||
""" This class will delete the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
scenarios = cast_utils.generate_scenarios("cast_delete")
|
||||
scenarios = utils.generate_scenarios("cast_delete",
|
||||
cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
super(CastsDeleteTestCase, self).setUp()
|
||||
|
|
|
@ -29,7 +29,8 @@ class CastsMultipleDeleteTestCase(BaseTestGenerator):
|
|||
""" This class will delete the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/obj/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_delete_multiple")
|
||||
scenarios = utils.generate_scenarios("cast_delete_multiple",
|
||||
cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
super(CastsMultipleDeleteTestCase, self).setUp()
|
||||
|
|
|
@ -27,7 +27,7 @@ class CastsGetTestCase(BaseTestGenerator):
|
|||
""" This class will fetch the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/obj/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_get")
|
||||
scenarios = utils.generate_scenarios("cast_get", cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will create cast."""
|
||||
|
|
|
@ -27,8 +27,8 @@ class CastsGetDependentsAndDependencyTestCase(BaseTestGenerator):
|
|||
""" This class will fetch the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/'
|
||||
scenarios = cast_utils.generate_scenarios(
|
||||
"cast_get_dependencies_dependants")
|
||||
scenarios = utils.generate_scenarios(
|
||||
"cast_get_dependencies_dependants", cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will create cast."""
|
||||
|
|
|
@ -18,7 +18,8 @@ class CastsGetNodeTestCase(BaseTestGenerator):
|
|||
""" This class will fetch the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/nodes/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_get_node")
|
||||
scenarios = utils.generate_scenarios("cast_get_node",
|
||||
cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will create cast."""
|
||||
|
|
|
@ -27,7 +27,7 @@ class CastsGetSqlTestCase(BaseTestGenerator):
|
|||
""" This class will fetch the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
url = '/browser/cast/'
|
||||
scenarios = cast_utils.generate_scenarios("cast_get_sql")
|
||||
scenarios = utils.generate_scenarios("cast_get_sql", cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will create cast."""
|
||||
|
|
|
@ -29,7 +29,7 @@ class CastsPutTestCase(BaseTestGenerator):
|
|||
url = '/browser/cast/obj/'
|
||||
""" This class will fetch the cast node added under database node. """
|
||||
skip_on_database = ['gpdb']
|
||||
scenarios = cast_utils.generate_scenarios("cast_put")
|
||||
scenarios = utils.generate_scenarios("cast_put", cast_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
""" This function will create cast."""
|
||||
|
|
|
@ -17,24 +17,6 @@ with open(CURRENT_PATH + "/cast_test_data.json") as data_file:
|
|||
test_cases = json.load(data_file)
|
||||
|
||||
|
||||
def generate_scenarios(key):
|
||||
"""
|
||||
This function generates the test case scenarios according to key given
|
||||
to it, e.g. key=ADD, key=update etc.
|
||||
:param key: for which operation generate the test scenario
|
||||
:type key: str
|
||||
:return: scenarios
|
||||
:rtype: list
|
||||
"""
|
||||
scenarios = []
|
||||
for scenario in test_cases[key]:
|
||||
test_name = scenario["name"]
|
||||
scenario.pop("name")
|
||||
tup = (test_name, dict(scenario))
|
||||
scenarios.append(tup)
|
||||
return scenarios
|
||||
|
||||
|
||||
def api_get_cast(self, cast_id):
|
||||
return self.tester.get(
|
||||
self.url + str(SERVER_GROUP) + '/' + str(
|
||||
|
|
|
@ -0,0 +1,441 @@
|
|||
{
|
||||
"create_language": [
|
||||
{
|
||||
"name": "Create trusted language",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": true,
|
||||
"test_data": {
|
||||
"name": "PLACE_HOLDER",
|
||||
"lanowner": "PLACE_HOLDER",
|
||||
"trusted": true,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"laninl": "btint2sortsupport",
|
||||
"lanval": "fmgr_c_validator"
|
||||
},
|
||||
"parameters_to_compare": [
|
||||
"name",
|
||||
"lanowner",
|
||||
"trusted",
|
||||
"lanproc",
|
||||
"laninl",
|
||||
"lanval"
|
||||
],
|
||||
"mocking_required": false,
|
||||
"mock_data": {},
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Missing required parameter while creating langauge",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"missing_name": true,
|
||||
"test_data": {
|
||||
"name": "PLACE_HOLDER",
|
||||
"lanowner": "PLACE_HOLDER",
|
||||
"trusted": true,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"laninl": "btint2sortsupport",
|
||||
"lanval": "fmgr_c_validator"
|
||||
},
|
||||
"expected_data": {
|
||||
"status_code": 410,
|
||||
"message": "Could not find the required parameter"
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while crerating langauge with missing langauge pack",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"missing_lang_pack": true,
|
||||
"test_data": {
|
||||
"name": "PLACE_HOLDER",
|
||||
"lanowner": "PLACE_HOLDER",
|
||||
"trusted": true,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"laninl": "btint2sortsupport",
|
||||
"lanval": "fmgr_c_validator"
|
||||
},
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Could not find the required parameter"
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting properties created langauge",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"error_in_properties": true,
|
||||
"test_data": {
|
||||
"name": "PLACE_HOLDER",
|
||||
"lanowner": "PLACE_HOLDER",
|
||||
"trusted": true,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"laninl": "btint2sortsupport",
|
||||
"lanval": "fmgr_c_validator"
|
||||
},
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Error while getting properties created langauge."
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(True, True), (False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"get_language": [
|
||||
{
|
||||
"name": "Language properties get test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Language properties get test case using wrong id",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"invalid_id": true,
|
||||
"expected_data": {
|
||||
"status_code": 410,
|
||||
"message": "Could not find the required language"
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting created langauges properties",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"error_in_language_properties": true,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while getting langauges"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting created langauges acl",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"language_acl": true,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while getting langauges acl"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "PLACE_HOLDER"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Language list get test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": true,
|
||||
"language_list": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting created langauges list",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"language_list": true,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while getting langauges"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"get_language_node": [
|
||||
{
|
||||
"name": "Language get nodes test case",
|
||||
"url": "/browser/language/nodes/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting language nodes",
|
||||
"url": "/browser/language/nodes/",
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Could not find the required parameter"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_2darray",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Single language get node test case",
|
||||
"url": "/browser/language/nodes/",
|
||||
"is_positive_test": true,
|
||||
"language_node": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting single language node",
|
||||
"url": "/browser/language/nodes/",
|
||||
"language_node": true,
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Could not find the required parameter"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_2darray",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"update_language": [
|
||||
{
|
||||
"name": "Language update test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": true,
|
||||
"test_data": {
|
||||
"id": "PLACE_HOLDER",
|
||||
"description": "This is test comment."
|
||||
},
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while updating the created language",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"test_data": {
|
||||
"id": "PLACE_HOLDER",
|
||||
"description": "This is test comment."
|
||||
},
|
||||
"error_in_update_language": true,
|
||||
"dummy_dict": {
|
||||
"rows": [
|
||||
{
|
||||
"oid": 34155,
|
||||
"name": "language_4f726c8",
|
||||
"trusted": true,
|
||||
"acl": null,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"lanval": null,
|
||||
"description": null,
|
||||
"lanowner": "postgres",
|
||||
"laninl": null,
|
||||
"seclabels": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "PLACE_HOLDER"
|
||||
},
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while updating properties"
|
||||
}
|
||||
}
|
||||
],
|
||||
"get_language_sql": [
|
||||
{
|
||||
"name": "Language get sql test case",
|
||||
"url": "/browser/language/sql/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Language get sql test case using wrong language id",
|
||||
"url": "/browser/language/sql/",
|
||||
"missing_paramter": true,
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 410,
|
||||
"message": "Could not find the required parameter"
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting language functions",
|
||||
"url": "/browser/language/sql/",
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Error while getting language sql"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"get_language_function_and_template": [
|
||||
{
|
||||
"name": "Language get functions test case",
|
||||
"url": "/browser/language/get_functions/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Language get templates test case",
|
||||
"url": "/browser/language/get_templates/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting language functions",
|
||||
"url": "/browser/language/get_functions/",
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Error while getting language functions"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting language template",
|
||||
"url": "/browser/language/get_templates/",
|
||||
"is_positive_test": false,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Error while getting language templates"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_dict",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"get_language_dependent": [
|
||||
{
|
||||
"name": "Language get dependency test case",
|
||||
"url": "/browser/language/dependent/",
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
}
|
||||
],
|
||||
"get_language_dependency": [
|
||||
{
|
||||
"name": "Language get dependency test case",
|
||||
"url": "/browser/language/dependency/",
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
}
|
||||
}
|
||||
],
|
||||
"language_delete": [
|
||||
{
|
||||
"name": "Language delete test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": true,
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Error while getting getting a language to delete",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"error_in_getting_language": true,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while deleting properties"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
||||
"return_value": "(False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while deleting the created langauge",
|
||||
"url": "/browser/language/obj/",
|
||||
"is_positive_test": false,
|
||||
"error_in_deleting_language": true,
|
||||
"expected_data": {
|
||||
"status_code": 500,
|
||||
"message": "Internal server error while deleting properties"
|
||||
},
|
||||
"mocking_required": true,
|
||||
"mock_data": {
|
||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
||||
"return_value": "(True, True), (False, 'Mocked Internal Server Error')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"delete_multiple": [
|
||||
{
|
||||
"name": "Language delete test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
},
|
||||
{
|
||||
"name": "Language delete test case",
|
||||
"url": "/browser/language/obj/",
|
||||
"mocking_required": false,
|
||||
"mock_data": {}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -11,6 +11,7 @@ from __future__ import print_function
|
|||
|
||||
import json
|
||||
import uuid
|
||||
import sys
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
|
@ -19,15 +20,23 @@ from regression import parent_node_dict
|
|||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as language_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesAddTestCase(BaseTestGenerator):
|
||||
skip_on_database = ['gpdb']
|
||||
scenarios = [
|
||||
('Language add test case', dict(url='/browser/language/obj/'))
|
||||
]
|
||||
scenarios = utils.generate_scenarios('create_language',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
super(LanguagesAddTestCase, self).setUp()
|
||||
db_user = self.server['username']
|
||||
self.data = self.test_data
|
||||
self.data['name'] = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
self.data['lanowner'] = db_user
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
|
@ -42,41 +51,48 @@ class LanguagesAddTestCase(BaseTestGenerator):
|
|||
def runTest(self):
|
||||
"""This function will add language under test database."""
|
||||
|
||||
db_user = self.server['username']
|
||||
actual_status_code = ''
|
||||
expected_status_code = ''
|
||||
if self.is_positive_test:
|
||||
response = self.create_language()
|
||||
actual_status_code = response.status_code
|
||||
expected_output = language_utils.verify_language(self)
|
||||
expected_status_code = self.expected_data["status_code"]
|
||||
self.assertDictEqual(expected_output, self.data)
|
||||
else:
|
||||
if hasattr(self, "missing_name"):
|
||||
del self.data["name"]
|
||||
response = self.create_language()
|
||||
actual_status_code = response.status_code
|
||||
expected_status_code = self.expected_data["status_code"]
|
||||
if hasattr(self, "missing_lang_pack"):
|
||||
self.data['name'] = 'plperlu'
|
||||
response = self.create_language()
|
||||
actual_status_code = response.status_code
|
||||
expected_status_code = self.expected_data["status_code"]
|
||||
|
||||
self.data = {
|
||||
"lanacl": [],
|
||||
"laninl": "btint2sortsupport",
|
||||
"lanowner": db_user,
|
||||
"lanproc": "plpgsql_call_handler",
|
||||
"lanval": "fmgr_c_validator",
|
||||
"name": "language_%s" % str(uuid.uuid4())[1:8],
|
||||
"seclabels": [],
|
||||
"template_list": [
|
||||
"plperl",
|
||||
"plperlu",
|
||||
"plpython2u",
|
||||
"plpython3u",
|
||||
"plpythonu",
|
||||
"pltcl",
|
||||
"pltclu"
|
||||
],
|
||||
"trusted": "true"
|
||||
}
|
||||
if hasattr(self, "error_in_properties"):
|
||||
with patch(self.mock_data["function_name"],
|
||||
side_effect=[eval(self.mock_data["return_value"])]):
|
||||
response = self.create_language()
|
||||
actual_status_code = response.status_code
|
||||
expected_status_code = self.expected_data["status_code"]
|
||||
self.assertEquals(actual_status_code, expected_status_code)
|
||||
|
||||
response = self.tester.post(
|
||||
def create_language(self):
|
||||
"""This function will add language under test database."""
|
||||
return self.tester.post(
|
||||
self.url + str(utils.SERVER_GROUP) + '/' +
|
||||
str(self.server_id) + '/' + str(self.db_id) + '/',
|
||||
data=json.dumps(self.data),
|
||||
content_type='html/json')
|
||||
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
|
||||
language_utils.delete_language(
|
||||
self.server, self.db_name, self.data['name']
|
||||
)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
||||
if self.is_positive_test or hasattr(self, "error_in_properties"):
|
||||
language_utils.delete_language(
|
||||
self.server, self.db_name, self.data['name'])
|
||||
database_utils.disconnect_database(self, self.server_id,
|
||||
self.db_id)
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
##########################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
|
@ -18,11 +17,15 @@ from regression import parent_node_dict
|
|||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as language_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesDeleteTestCase(BaseTestGenerator):
|
||||
scenarios = [
|
||||
('Language delete test case', dict(url='/browser/language/obj/'))
|
||||
]
|
||||
scenarios = utils.generate_scenarios(
|
||||
'language_delete', language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
|
@ -42,12 +45,37 @@ class LanguagesDeleteTestCase(BaseTestGenerator):
|
|||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function will delete language under test database."""
|
||||
"""This function contains the test cases for delete language"""
|
||||
|
||||
response = self.tester.delete("{0}{1}/{2}/{3}/{4}".format(
|
||||
if self.is_positive_test:
|
||||
response = self.delete_language()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
elif hasattr(self, 'error_in_getting_language'):
|
||||
with patch(self.mock_data["function_name"],
|
||||
return_value=[eval(self.mock_data["return_value"])]):
|
||||
response = self.delete_language()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
elif self.error_in_deleting_language:
|
||||
# with patch('pgadmin.utils.driver.psycopg2.connection.Connection'
|
||||
# '.execute_scalar',
|
||||
# side_effect=[(True, True), (
|
||||
# False, self.expected_data["message"])]):
|
||||
with patch(self.mock_data["function_name"],
|
||||
side_effect=[eval(self.mock_data["return_value"])]):
|
||||
response = self.delete_language()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def delete_language(self):
|
||||
"""This function will delete language under test database."""
|
||||
return self.tester.delete("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), follow_redirects=True)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function disconnect the test database."""
|
||||
|
|
|
@ -21,9 +21,8 @@ from . import utils as language_utils
|
|||
|
||||
|
||||
class LanguagesDeleteMultipleTestCase(BaseTestGenerator):
|
||||
scenarios = [
|
||||
('Language delete test case', dict(url='/browser/language/obj/'))
|
||||
]
|
||||
scenarios = utils.generate_scenarios('delete_multiple',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import uuid
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as language_utils
|
||||
|
||||
|
||||
class LanguagesGetDependencyTestCase(BaseTestGenerator):
|
||||
scenarios = utils.generate_scenarios(
|
||||
'get_language_dependency', language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
self.db_name = self.server_data["db_name"]
|
||||
self.lang_name = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to database.")
|
||||
self.language_id = language_utils.create_language(self.server,
|
||||
self.db_name,
|
||||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function contains the test cases for language dependency"""
|
||||
|
||||
response = self.get_language_dependency()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_dependency(self):
|
||||
"""
|
||||
This function will get the language dependency
|
||||
:return:language dependency response
|
||||
"""
|
||||
return self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), follow_redirects=True)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
|
@ -0,0 +1,64 @@
|
|||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import uuid
|
||||
from regression import parent_node_dict
|
||||
from . import utils as language_utils
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
|
||||
|
||||
class LanguagesGetDependentTestCase(BaseTestGenerator):
|
||||
scenarios = utils.generate_scenarios(
|
||||
'get_language_dependent', language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
self.db_name = self.server_data["db_name"]
|
||||
self.lang_name = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to database.")
|
||||
self.language_id = language_utils.create_language(self.server,
|
||||
self.db_name,
|
||||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function contains the test cases for language dependent"""
|
||||
|
||||
response = self.get_language_dependency()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_dependency(self):
|
||||
"""
|
||||
This function will get the language dependency
|
||||
:return:language dependency response
|
||||
"""
|
||||
return self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), follow_redirects=True)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
|
@ -10,7 +10,7 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import uuid
|
||||
|
||||
import sys
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
|
@ -18,11 +18,102 @@ from regression import parent_node_dict
|
|||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as language_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesGetTestCase(BaseTestGenerator):
|
||||
scenarios = [
|
||||
('Language get test case', dict(url='/browser/language/obj/'))
|
||||
]
|
||||
scenarios = utils.generate_scenarios('get_language',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
self.db_name = self.server_data["db_name"]
|
||||
self.lang_name = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to database.")
|
||||
if self.is_positive_test:
|
||||
self.language_id = language_utils.create_language(self.server,
|
||||
self.db_name,
|
||||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function contains the test cases for language get"""
|
||||
|
||||
actual_response_code = ''
|
||||
expected_status_code = 'none'
|
||||
if self.is_positive_test:
|
||||
if hasattr(self, 'language_list'):
|
||||
response = self.get_language_list()
|
||||
else:
|
||||
response = self.get_language_properties()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
else:
|
||||
if hasattr(self, 'invalid_id'):
|
||||
self.language_id = 9999
|
||||
response = self.get_language_properties()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
elif hasattr(self, 'language_list') or \
|
||||
hasattr(self, 'error_in_language_properties'):
|
||||
with patch(self.mock_data["function_name"],
|
||||
return_value=eval(self.mock_data["return_value"])):
|
||||
|
||||
if hasattr(self, 'language_list'):
|
||||
response = self.get_language_list()
|
||||
|
||||
elif hasattr(self, 'error_in_language_properties'):
|
||||
self.language_id = 9999
|
||||
response = self.get_language_properties()
|
||||
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
elif self.language_acl:
|
||||
dummy_dict = {"rows": {"data1": "1", "data2": "2"}}
|
||||
self.mock_data['return_value'] = [(True, dummy_dict), (
|
||||
False, self.expected_data["message"])]
|
||||
with patch(self.mock_data["function_name"],
|
||||
side_effect=self.mock_data["return_value"]):
|
||||
self.language_id = 9999
|
||||
response = self.get_language_properties()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_properties(self):
|
||||
return self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), follow_redirects=True)
|
||||
|
||||
def get_language_list(self):
|
||||
return self.tester.get("{0}{1}/{2}/{3}/".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id),
|
||||
follow_redirects=True)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
if self.is_positive_test:
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
||||
|
||||
|
||||
class LanguagesGetNodesTestCase(BaseTestGenerator):
|
||||
scenarios = utils.generate_scenarios('get_language_node',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
|
@ -44,15 +135,39 @@ class LanguagesGetTestCase(BaseTestGenerator):
|
|||
def runTest(self):
|
||||
"""This function will get the language under test database."""
|
||||
|
||||
response = self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
if self.is_positive_test:
|
||||
if hasattr(self, 'language_node'):
|
||||
response = self.get_language_node()
|
||||
else:
|
||||
response = self.get_language_nodes()
|
||||
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
else:
|
||||
with patch(self.mock_data["function_name"],
|
||||
return_value=eval(self.mock_data["return_value"])):
|
||||
if hasattr(self, 'language_node'):
|
||||
response = self.get_language_node()
|
||||
else:
|
||||
response = self.get_language_nodes()
|
||||
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_nodes(self):
|
||||
return self.tester.get("{0}{1}/{2}/{3}/".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id),
|
||||
follow_redirects=True)
|
||||
|
||||
def get_language_node(self):
|
||||
return self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), follow_redirects=True)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import uuid
|
||||
import sys
|
||||
from . import utils as language_utils
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from regression import parent_node_dict
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesGetFunctionAndTemplateTestCase(BaseTestGenerator):
|
||||
scenarios = utils.generate_scenarios(
|
||||
'get_language_function_and_template', language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
self.db_name = self.server_data["db_name"]
|
||||
self.lang_name = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to database.")
|
||||
self.language_id = language_utils.create_language(self.server,
|
||||
self.db_name,
|
||||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function will get the language under test database."""
|
||||
if self.is_positive_test:
|
||||
response = self.get_language_functions_template()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
else:
|
||||
with patch(self.mock_data["function_name"],
|
||||
return_value=eval(self.mock_data["return_value"])):
|
||||
response = self.get_language_functions_template()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_functions_template(self):
|
||||
"""
|
||||
This function will get the language function
|
||||
:return:language function response
|
||||
"""
|
||||
return self.tester.get("{0}{1}/{2}/{3}/".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id),
|
||||
follow_redirects=True)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
|
@ -11,19 +11,23 @@ from __future__ import print_function
|
|||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import sys
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as language_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesPutTestCase(BaseTestGenerator):
|
||||
scenarios = [
|
||||
('Language update test case', dict(url='/browser/language/obj/'))
|
||||
]
|
||||
scenarios = utils.generate_scenarios('update_language',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
|
@ -43,17 +47,29 @@ class LanguagesPutTestCase(BaseTestGenerator):
|
|||
|
||||
def runTest(self):
|
||||
"""This function will update the language under test database."""
|
||||
self.test_data['id'] = self.language_id
|
||||
if self.is_positive_test:
|
||||
response = self.update_language()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
data = \
|
||||
{
|
||||
"id": self.language_id,
|
||||
"description": "This is test comment."
|
||||
}
|
||||
response = self.tester.put("{0}{1}/{2}/{3}/{4}".format(
|
||||
elif self.error_in_update_language:
|
||||
self.mock_data['return_value'] = [(True, self.dummy_dict), (
|
||||
False, self.expected_data["message"])]
|
||||
with patch(self.mock_data["function_name"],
|
||||
side_effect=self.mock_data['return_value']):
|
||||
response = self.update_language()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def update_language(self):
|
||||
|
||||
return self.tester.put("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id), data=json.dumps(data),
|
||||
self.language_id), data=json.dumps(self.test_data),
|
||||
follow_redirects=True)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import uuid
|
||||
import sys
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from . import utils as language_utils
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import \
|
||||
utils as database_utils
|
||||
|
||||
if sys.version_info < (3, 3):
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class LanguagesGetSql(BaseTestGenerator):
|
||||
scenarios = utils.generate_scenarios('get_language_sql',
|
||||
language_utils.test_cases)
|
||||
|
||||
def setUp(self):
|
||||
self.server_data = parent_node_dict["database"][-1]
|
||||
self.server_id = self.server_data["server_id"]
|
||||
self.db_id = self.server_data['db_id']
|
||||
self.db_name = self.server_data["db_name"]
|
||||
self.lang_name = "language_%s" % str(uuid.uuid4())[1:8]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to database.")
|
||||
self.language_id = language_utils.create_language(self.server,
|
||||
self.db_name,
|
||||
self.lang_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function contains the test cases for language sql"""
|
||||
if self.is_positive_test:
|
||||
response = self.get_language_sql()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
elif hasattr(self, 'missing_paramter'):
|
||||
self.language_id = 888888
|
||||
response = self.get_language_sql()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
else:
|
||||
with patch(self.mock_data["function_name"],
|
||||
return_value=eval(self.mock_data["return_value"])):
|
||||
response = self.get_language_sql()
|
||||
actual_response_code = response.status_code
|
||||
expected_status_code = self.expected_data['status_code']
|
||||
self.assertEquals(actual_response_code, expected_status_code)
|
||||
|
||||
def get_language_sql(self):
|
||||
"""
|
||||
This function will get the language function
|
||||
:return:language function response
|
||||
"""
|
||||
return self.tester.get("{0}{1}/{2}/{3}/{4}".format(
|
||||
self.url, utils.SERVER_GROUP, self.server_id, self.db_id,
|
||||
self.language_id),
|
||||
follow_redirects=True)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function delete added language and
|
||||
disconnect the test database."""
|
||||
language_utils.delete_language(self.server, self.db_name,
|
||||
self.lang_name)
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
|
@ -11,9 +11,14 @@ from __future__ import print_function
|
|||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import os
|
||||
import json
|
||||
from regression.python_test_utils.test_utils import get_db_connection
|
||||
|
||||
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(CURRENT_PATH + "/language_test_data.json") as data_file:
|
||||
test_cases = json.load(data_file)
|
||||
|
||||
|
||||
def create_language(server, db_name, lang_name):
|
||||
"""
|
||||
|
@ -51,31 +56,39 @@ def create_language(server, db_name, lang_name):
|
|||
traceback.print_exc(file=sys.stderr)
|
||||
|
||||
|
||||
def verify_language(server, db_name, lang_name):
|
||||
def verify_language(self):
|
||||
"""
|
||||
This function verifies the language exist in database or not.
|
||||
:param server: server details
|
||||
:type server: dict
|
||||
:param db_name: database name
|
||||
:type db_name: str
|
||||
:param lang_name: language name
|
||||
:type lang_name: str
|
||||
:return language: language record
|
||||
:rtype: tuple
|
||||
"""
|
||||
try:
|
||||
connection = get_db_connection(db_name,
|
||||
server['username'],
|
||||
server['db_password'],
|
||||
server['host'],
|
||||
server['port'],
|
||||
server['sslmode'])
|
||||
connection = get_db_connection(self.db_name,
|
||||
self.server['username'],
|
||||
self.server['db_password'],
|
||||
self.server['host'],
|
||||
self.server['port'],
|
||||
self.server['sslmode'])
|
||||
pg_cursor = connection.cursor()
|
||||
pg_cursor.execute("SELECT oid from pg_language where lanname='%s'" %
|
||||
lang_name)
|
||||
pg_cursor.execute("SELECT * from pg_language where lanname='%s'" %
|
||||
self.data["name"])
|
||||
pg_cursor.execute("select pl.lanname, "
|
||||
"(select rolname from pg_authid where oid "
|
||||
"= pl.lanowner) as lanowner, "
|
||||
"pl.lanpltrusted, "
|
||||
"( select prosrc from pg_proc where "
|
||||
"oid = pl.lanplcallfoid) as lanplcallfoid, "
|
||||
"( select prosrc from pg_proc where oid = "
|
||||
"pl.laninline) as laninline, "
|
||||
"( select prosrc from pg_proc where oid = "
|
||||
"pl.lanvalidator) as lanvalidator "
|
||||
"from pg_language pl where lanname='%s'" %
|
||||
self.data["name"])
|
||||
language = pg_cursor.fetchall()
|
||||
expected_output = make_dict(self.parameters_to_compare,
|
||||
list(language[0]))
|
||||
|
||||
connection.close()
|
||||
return language
|
||||
|
||||
return expected_output
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
||||
|
@ -111,3 +124,14 @@ def delete_language(server, db_name, lang_name):
|
|||
connection.close()
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
||||
|
||||
def make_dict(paramaters, actual_data):
|
||||
expected_output = {}
|
||||
|
||||
for key in paramaters:
|
||||
for value in actual_data:
|
||||
expected_output[key] = value
|
||||
actual_data.remove(value)
|
||||
break
|
||||
return expected_output
|
||||
|
|
|
@ -53,7 +53,7 @@ def login_tester_account(tester):
|
|||
:return: None
|
||||
"""
|
||||
if os.environ['PGADMIN_SETUP_EMAIL'] and \
|
||||
os.environ['PGADMIN_SETUP_PASSWORD']:
|
||||
os.environ['PGADMIN_SETUP_PASSWORD']:
|
||||
email = os.environ['PGADMIN_SETUP_EMAIL']
|
||||
password = os.environ['PGADMIN_SETUP_PASSWORD']
|
||||
tester.login(email, password)
|
||||
|
@ -280,8 +280,7 @@ def create_constraint(server,
|
|||
pg_cursor.execute('''
|
||||
ALTER TABLE "%s"
|
||||
ADD CONSTRAINT "%s" %s (some_column)
|
||||
''' % (table_name, constraint_name, constraint_type.upper())
|
||||
)
|
||||
''' % (table_name, constraint_name, constraint_type.upper()))
|
||||
|
||||
connection.set_isolation_level(old_isolation_level)
|
||||
connection.commit()
|
||||
|
@ -865,13 +864,17 @@ def _cleanup(tester, app_starter):
|
|||
"""This function use to cleanup the created the objects(servers, databases,
|
||||
schemas etc) during the test suite run"""
|
||||
try:
|
||||
test_servers = regression.parent_node_dict["server"] + \
|
||||
test_servers = \
|
||||
regression.parent_node_dict["server"] + \
|
||||
regression.node_info_dict["sid"]
|
||||
test_databases = regression.parent_node_dict["database"] + \
|
||||
test_databases = \
|
||||
regression.parent_node_dict["database"] + \
|
||||
regression.node_info_dict["did"]
|
||||
test_table_spaces = regression.parent_node_dict["tablespace"] + \
|
||||
test_table_spaces = \
|
||||
regression.parent_node_dict["tablespace"] + \
|
||||
regression.node_info_dict["tsid"]
|
||||
test_roles = regression.parent_node_dict["role"] + \
|
||||
test_roles = \
|
||||
regression.parent_node_dict["role"] + \
|
||||
regression.node_info_dict["lrid"]
|
||||
# Drop databases
|
||||
for database in test_databases:
|
||||
|
@ -1175,3 +1178,23 @@ def print_and_store_coverage_report(cov):
|
|||
if os.path.exists(cov_dir):
|
||||
shutil.rmtree(cov_dir)
|
||||
cov.html_report(directory=cov_dir)
|
||||
|
||||
|
||||
def generate_scenarios(key, test_cases):
|
||||
"""
|
||||
This function generates the test case scenarios according to key given
|
||||
to it, e.g. key=ADD, key=update etc.
|
||||
:param key: for which operation generate the test scenario
|
||||
:type key: str
|
||||
:param test_cases
|
||||
:type test_cases: list
|
||||
:return: scenarios
|
||||
:rtype: list
|
||||
"""
|
||||
scenarios = []
|
||||
for scenario in test_cases[key]:
|
||||
test_name = scenario["name"]
|
||||
scenario.pop("name")
|
||||
tup = (test_name, dict(scenario))
|
||||
scenarios.append(tup)
|
||||
return scenarios
|
||||
|
|
Loading…
Reference in New Issue