diff --git a/web/pgadmin/tools/backup/tests/test_check_utility_exists_route_backup.py b/web/pgadmin/tools/backup/tests/test_check_utility_exists_route_backup.py new file mode 100644 index 00000000..b01704b3 --- /dev/null +++ b/web/pgadmin/tools/backup/tests/test_check_utility_exists_route_backup.py @@ -0,0 +1,41 @@ +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2018, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +import sys +import json +from pgadmin.utils.route import BaseTestGenerator +from regression.python_test_utils.test_utils import\ + check_binary_path_or_skip_test + +if sys.version_info < (3, 3): + from mock import patch +else: + from unittest.mock import patch + + +class TestUtilityCheckRouteCase(BaseTestGenerator): + """Test to checks the utility route for Backup""" + + scenarios = [ + ('Check utility path route for backup utility', { + 'url': '/backup/utility_exists/{0}/objects', + 'expected_success_value': 1 + }) + ] + + def setUp(self): + check_binary_path_or_skip_test(self) + + @patch('pgadmin.tools.backup.is_utility_exists') + def runTest(self, is_utility_exists_mock): + is_utility_exists_mock.return_value = False + response = self.tester.get(self.url.format(1)) + self.assertEquals(response.status_code, 200) + response = json.loads(response.data.decode('utf-8')) + self.assertEquals(self.expected_success_value, response['success']) diff --git a/web/pgadmin/tools/import_export/tests/__init__.py b/web/pgadmin/tools/import_export/tests/__init__.py new file mode 100644 index 00000000..590026ad --- /dev/null +++ b/web/pgadmin/tools/import_export/tests/__init__.py @@ -0,0 +1,8 @@ +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2018, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## diff --git a/web/pgadmin/tools/import_export/tests/test_check_utility_exists_route_import_export.py b/web/pgadmin/tools/import_export/tests/test_check_utility_exists_route_import_export.py new file mode 100644 index 00000000..ae04cf59 --- /dev/null +++ b/web/pgadmin/tools/import_export/tests/test_check_utility_exists_route_import_export.py @@ -0,0 +1,41 @@ +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2018, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +import sys +import json +from pgadmin.utils.route import BaseTestGenerator +from regression.python_test_utils.test_utils import\ + check_binary_path_or_skip_test + +if sys.version_info < (3, 3): + from mock import patch +else: + from unittest.mock import patch + + +class TestUtilityCheckRouteCase(BaseTestGenerator): + """Test to checks the utility route for Import-Export""" + + scenarios = [ + ('Check utility path route for import export utility', { + 'url': '/import_export/utility_exists/{0}', + 'expected_success_value': 1 + }) + ] + + def setUp(self): + check_binary_path_or_skip_test(self) + + @patch('pgadmin.tools.import_export.is_utility_exists') + def runTest(self, is_utility_exists_mock): + is_utility_exists_mock.return_value = False + response = self.tester.get(self.url.format(1)) + self.assertEquals(response.status_code, 200) + response = json.loads(response.data.decode('utf-8')) + self.assertEquals(self.expected_success_value, response['success']) diff --git a/web/pgadmin/tools/maintenance/tests/test_check_utility_exists_route_maintenance.py b/web/pgadmin/tools/maintenance/tests/test_check_utility_exists_route_maintenance.py new file mode 100644 index 00000000..cb079989 --- /dev/null +++ b/web/pgadmin/tools/maintenance/tests/test_check_utility_exists_route_maintenance.py @@ -0,0 +1,41 @@ +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2018, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +import sys +import json +from pgadmin.utils.route import BaseTestGenerator +from regression.python_test_utils.test_utils import\ + check_binary_path_or_skip_test + +if sys.version_info < (3, 3): + from mock import patch +else: + from unittest.mock import patch + + +class TestUtilityCheckRouteCase(BaseTestGenerator): + """Test to checks the utility route for maintenance""" + + scenarios = [ + ('Check utility path route for maintenance utility', { + 'url': '/maintenance/utility_exists/{0}', + 'expected_success_value': 1 + }) + ] + + def setUp(self): + check_binary_path_or_skip_test(self) + + @patch('pgadmin.tools.maintenance.is_utility_exists') + def runTest(self, is_utility_exists_mock): + is_utility_exists_mock.return_value = False + response = self.tester.get(self.url.format(1)) + self.assertEquals(response.status_code, 200) + response = json.loads(response.data.decode('utf-8')) + self.assertEquals(self.expected_success_value, response['success']) diff --git a/web/pgadmin/tools/restore/tests/test_check_utility_exists_route_restore.py b/web/pgadmin/tools/restore/tests/test_check_utility_exists_route_restore.py new file mode 100644 index 00000000..2ec980c2 --- /dev/null +++ b/web/pgadmin/tools/restore/tests/test_check_utility_exists_route_restore.py @@ -0,0 +1,41 @@ +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2018, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +import sys +import json +from pgadmin.utils.route import BaseTestGenerator +from regression.python_test_utils.test_utils import\ + check_binary_path_or_skip_test + +if sys.version_info < (3, 3): + from mock import patch +else: + from unittest.mock import patch + + +class TestUtilityCheckRouteCase(BaseTestGenerator): + """Test to checks the utility route for Restore""" + + scenarios = [ + ('Check utility path route for restore utility', { + 'url': '/restore/utility_exists/{0}', + 'expected_success_value': 1 + }) + ] + + def setUp(self): + check_binary_path_or_skip_test(self) + + @patch('pgadmin.tools.restore.is_utility_exists') + def runTest(self, is_utility_exists_mock): + is_utility_exists_mock.return_value = False + response = self.tester.get(self.url.format(1)) + self.assertEquals(response.status_code, 200) + response = json.loads(response.data.decode('utf-8')) + self.assertEquals(self.expected_success_value, response['success']) diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py index 5b1225ce..311eeef4 100644 --- a/web/regression/python_test_utils/test_utils.py +++ b/web/regression/python_test_utils/test_utils.py @@ -964,3 +964,15 @@ def get_server_type(server): return 'pg' except Exception: traceback.print_exc(file=sys.stderr) + + +def check_binary_path_or_skip_test(cls): + if 'default_binary_paths' not in cls.server or \ + cls.server['default_binary_paths'] is None or \ + cls.server['type'] not in cls.server['default_binary_paths'] or \ + cls.server['default_binary_paths'][cls.server['type']] == '': + cls.skipTest( + "default_binary_paths is not set for the server {0}".format( + cls.server['name'] + ) + )