class FeaturesTests(unittest.TestCase): """ Test cases for skipping """ def setUp(self): pass def tearDown(self): pass @unittest.skipUnless(Features().haveApi(), "skipping if lack of API") def testHaveApi(self): """Test should be run all the time""" self.assertTrue(Features().haveApi()) @unittest.skipIf(Features().haveApi(), "requires API to run") def testNotHaveApi(self): self.fail("Test should have been skipped") @unittest.skipUnless(Features().testNever(), "tests for never execution") def testNever(self): self.fail("Test should have been skipped") def testMySqlTestServer(self): self.assertFalse(Features().haveMySqlTestServer()) os.environ["MYSQLUP"] = "True" self.assertTrue(Features().haveMySqlTestServer()) del os.environ["MYSQLUP"] def testRbmqTestServer(self): # Might need to handle true case self.assertFalse(Features().haveRbmqTestServer()) def testCvsTestServer(self): self.assertFalse(Features().haveCvsTestServer()) def testSvnTestServer(self): self.assertFalse(Features().haveSvnTestServer()) def testSftpTestServer(self): self.assertFalse(Features().haveSftpTestServer()) def testToolsRuntime(self): self.assertFalse(Features().haveToolsRuntime()) def testHaveCCD(self): self.assertFalse(Features().haveCCD())
def testHaveCCD(self): self.assertFalse(Features().haveCCD())
def testToolsRuntime(self): self.assertFalse(Features().haveToolsRuntime())
def testSftpTestServer(self): self.assertFalse(Features().haveSftpTestServer())
def testCvsTestServer(self): self.assertFalse(Features().haveCvsTestServer())
def testRbmqTestServer(self): # Might need to handle true case self.assertFalse(Features().haveRbmqTestServer())
def testMySqlTestServer(self): self.assertFalse(Features().haveMySqlTestServer()) os.environ["MYSQLUP"] = "True" self.assertTrue(Features().haveMySqlTestServer()) del os.environ["MYSQLUP"]
def testHaveApi(self): """Test should be run all the time""" self.assertTrue(Features().haveApi())
def messageHandler(channel, method, header, body): # pylint: disable=unused-argument channel.basic_ack(delivery_tag=method.delivery_tag) if body == b"quit": channel.basic_cancel(consumer_tag="test_consumer_tag") channel.stop_consuming() logger.info("Message body %r -- done ", body) else: logger.info("Message body %r", body) time.sleep(1) # return @unittest.skipUnless(Features().haveRbmqTestServer() and inmain, "require Rbmq Test Environment and run from commandline") class MessageConsumerBasicTests(unittest.TestCase): def testConsumeBasic(self): """Test case: publish single text message basic authentication""" startTime = time.time() logger.debug("Starting") try: mqc = MessageQueueConnection() parameters = mqc._getConnectionParameters() # pylint: disable=protected-access connection = pika.BlockingConnection(parameters) channel = connection.channel() channel.exchange_declare(exchange="test_exchange", exchange_type="topic",
import sys import time import unittest import traceback from wwpdb.utils.db.MyDbUtil import MyDbConnect, MyDbQuery from wwpdb.utils.db.StatusHistorySchemaDef import StatusHistorySchemaDef from mmcif.io.IoAdapterPy import IoAdapterPy from wwpdb.utils.db.MyDbSqlGen import MyDbAdminSqlGen from wwpdb.utils.db.SchemaDefLoader import SchemaDefLoader from wwpdb.utils.testing.Features import Features @unittest.skipUnless(Features().haveMySqlTestServer(), "require MySql Test Environment") class StatusHistoryLoaderTests(unittest.TestCase): def __init__(self, methodName="runTest"): super(StatusHistoryLoaderTests, self).__init__(methodName) self.__lfh = sys.stderr self.__verbose = True self.__ioObj = IoAdapterPy(verbose=self.__verbose, log=self.__lfh) def setUp(self): self.__lfh = sys.stderr self.__verbose = True self.__msd = StatusHistorySchemaDef(verbose=self.__verbose, log=self.__lfh) # self.__databaseName = self.__msd.getDatabaseName() self.__databaseName = "da_internal"
from wwpdb.utils.db.BirdSchemaDef import BirdSchemaDef from wwpdb.utils.db.ChemCompSchemaDef import ChemCompSchemaDef from wwpdb.utils.db.PdbxSchemaDef import PdbxSchemaDef from wwpdb.utils.db.DaInternalSchemaDef import DaInternalSchemaDef from mmcif.io.IoAdapterCore import IoAdapterCore from mmcif_utils.bird.PdbxPrdIo import PdbxPrdIo from mmcif_utils.bird.PdbxFamilyIo import PdbxFamilyIo from mmcif_utils.bird.PdbxPrdUtils import PdbxPrdUtils from mmcif_utils.chemcomp.PdbxChemCompIo import PdbxChemCompIo from wwpdb.utils.testing.Features import Features @unittest.skipUnless(Features().haveMySqlTestServer(), "require MySql Test Environment") class SchemaDefLoaderDbTests(unittest.TestCase): def __init__(self, methodName="runTest"): super(SchemaDefLoaderDbTests, self).__init__(methodName) self.__lfh = sys.stderr self.__verbose = True self.__debug = False def setUp(self): self.__lfh = sys.stderr self.__verbose = True # default database self.__databaseName = "prdv4" self.__birdCachePath = "/data/components/prd-v3" self.__birdFamilyCachePath = "/data/components/family-v3" self.__ccCachePath = "/data/components/ligand-dict-v3"
import sys import os.path import time import unittest import logging # from wwpdb.utils.config.ConfigInfo import ConfigInfo, getSiteId from wwpdb.io.sftp.ArchiveIoSftp import ArchiveIoSftp from wwpdb.utils.testing.Features import Features # logger = logging.getLogger(__name__) @unittest.skipUnless(Features().haveSftpTestServer(), "Needs SFTP server for testing") class ArchiveIoSftpTests(unittest.TestCase): def setUp(self): self.__lfh = sys.stderr self.__verbose = False # self.__serverId = "BACKUP_SERVER_RDI2" self.__cI = ConfigInfo(siteId=getSiteId(), verbose=self.__verbose, log=self.__lfh) cD = self.__cI.get(self.__serverId, {}) self.__hostName = cD.get("HOST_NAME") self.__userName = cD.get("HOST_USERNAME") self.__hostPort = int(cD.get("HOST_PORT")) # self.__protocol = cD.get("HOST_PROTOCOL")
import sys from os import path sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) from commonsetup import TESTOUTPUT else: from .commonsetup import TESTOUTPUT # from wwpdb.utils.message_queue.MessageQueueConnection import MessageQueueConnection logging.basicConfig(level=logging.WARN, format='\n[%(levelname)s]-%(module)s.%(funcName)s: %(message)s') logger = logging.getLogger() from wwpdb.utils.testing.Features import Features @unittest.skipUnless(Features().haveRbmqTestServer(), 'require Rbmq Test Environment') class MessageQueueConnectionTests(unittest.TestCase): def setUp(self): pass def testPublishRequestAuthBasic(self): """ Test case: create connection with basic authenication and publish single text message. """ startTime = time.time() logger.debug("Starting") try: # mqc = MessageQueueConnection() parameters = mqc._getConnectionParameters() connection = pika.BlockingConnection(parameters)
else: from .commonsetup import TESTOUTPUT from wwpdb.utils.message_queue.MessagePublisher import MessagePublisher # logging.basicConfig(level=logging.INFO, format='\n[%(levelname)s]-%(module)s.%(funcName)s: %(message)s') logger = logging.getLogger() from wwpdb.utils.testing.Features import Features # This test could be run from main - it will load up a queue inmain=True if __name__ == '__main__' else False @unittest.skipUnless(Features().haveRbmqTestServer() and inmain, 'require Rbmq Test Environment and started from command line') class MessagePublisherBasicTests(unittest.TestCase): def setUp(self): self.__numMessages = 50 def testPublishMessages(self): """ Publish numMessages messages to the test queue - """ startTime = time.time() logger.debug("Starting") try: mp = MessagePublisher() # for ii in range(1, self.__numMessages + 1): message = "Test message %5d" % ii
from wwpdb.utils.message_queue.MessageConsumerBase import MessageConsumerBase from wwpdb.utils.message_queue.MessageQueueConnection import MessageQueueConnection from wwpdb.utils.testing.Features import Features # logging.basicConfig( level=logging.INFO, format="\n[%(levelname)s]-%(module)s.%(funcName)s: %(message)s") logger = logging.getLogger() # This test needs to run from main - otherwise will block inmain = True if __name__ == "__main__" else False @unittest.skipUnless(Features().haveRbmqTestServer(), "require Rbmq Test Environment") class MessageConsumer(MessageConsumerBase): def workerMethod(self, msgBody, deliveryTag=None): logger.info("Message body %r", msgBody) return True @unittest.skipUnless(Features().haveRbmqTestServer(), "require Rbmq Test Environment") @unittest.skipUnless(inmain, "require running from main()") class MessageConsumerBaseTests(unittest.TestCase): def testMessageConsumer(self): """Test case: run async consumer""" startTime = time.time() logger.info("Starting")
from wwpdb.utils.message_queue.MessagePublisher import MessagePublisher from wwpdb.utils.testing.Features import Features # logging.basicConfig( level=logging.INFO, format="\n[%(levelname)s]-%(module)s.%(funcName)s: %(message)s") logger = logging.getLogger() # This test could be run from main - it will load up a queue inmain = True if __name__ == "__main__" else False @unittest.skipUnless( Features().haveRbmqTestServer() and inmain, "require Rbmq Test Environment and started from command line") class MessagePublisherBasicTests(unittest.TestCase): def setUp(self): self.__numMessages = 50 def testPublishMessages(self): """Publish numMessages messages to the test queue -""" startTime = time.time() logger.debug("Starting") try: mp = MessagePublisher() # for ii in range(1, self.__numMessages + 1): message = "Test message %5d" % ii mp.publish(message,