Skip tests where appropriate on GPDB. Fixes #3190

Victoria & Joao @ Pivotal.
This commit is contained in:
Joao Pedro De Almeida Pereira
2018-03-13 15:32:34 -04:00
committed by Dave Page
parent 6b03cb78af
commit 876ce1799a
107 changed files with 453 additions and 285 deletions

View File

@@ -7,13 +7,14 @@
#
##############################################################
import traceback
import sys
import traceback
from abc import ABCMeta, abstractmethod
from importlib import import_module
from werkzeug.utils import find_modules
import config
import six
from werkzeug.utils import find_modules
from pgadmin.utils import server_utils
if sys.version_info < (2, 7):
import unittest2 as unittest
@@ -67,9 +68,9 @@ class TestsGeneratorRegistry(ABCMeta):
for module_name in all_modules:
try:
if "tests." in str(module_name) and not any(
str(module_name).startswith(
'pgadmin.' + str(exclude_pkg)
) for exclude_pkg in exclude_pkgs
str(module_name).startswith(
'pgadmin.' + str(exclude_pkg)
) for exclude_pkg in exclude_pkgs
):
import_module(module_name)
except ImportError:
@@ -80,6 +81,15 @@ class TestsGeneratorRegistry(ABCMeta):
class BaseTestGenerator(unittest.TestCase):
# Defining abstract method which will override by individual testcase.
def setUp(self):
super(BaseTestGenerator, self).setUp()
self.server_id = self.server_information["server_id"]
server_con = server_utils.connect_server(self, self.server_id)
if hasattr(self, 'skip_on_database'):
if 'data' in server_con and 'type' in server_con['data']:
if server_con['data']['type'] in self.skip_on_database:
self.skipTest('cannot run in: %s' % self.server['db_type'])
@classmethod
def setTestServer(cls, server):
cls.server = server
@@ -100,3 +110,7 @@ class BaseTestGenerator(unittest.TestCase):
@classmethod
def setDriver(cls, driver):
cls.driver = driver
@classmethod
def setServerInformation(cls, server_information):
cls.server_information = server_information

View File

@@ -0,0 +1,33 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from __future__ import print_function
import json
SERVER_URL = '/browser/server/obj/'
SERVER_CONNECT_URL = '/browser/server/connect/'
DUMMY_SERVER_GROUP = 10000
def connect_server(self, server_id):
"""
This function used to connect added server
:param self: class object of server's test class
:type self: class
:param server_id: server id
:type server_id: str
"""
response = self.tester.post(SERVER_CONNECT_URL + str(DUMMY_SERVER_GROUP) +
'/' + str(server_id),
data=dict(password=self.server['db_password']),
follow_redirects=True)
assert response.status_code == 200
response_data = json.loads(response.data.decode('utf-8'))
return response_data