예제 #1
0
 def __init__(self, cfg):
     self.log = logger.get_logger('Ping_Test')
     self.log.info(
         "Look at the modbus watchdog to check for false triggers")
     self.config = cfg
     self.ping = 0
     base.testingBase.__init__(self, cfg)
예제 #2
0
 def __init__(self, cfg):
     self.log = logger.get_logger('CT_Interval_Test')
     self.log.info(
         "Testing the interval that the current transformer is polled")
     self.config = cfg
     self.old_temp = 0.0
     self.old_time = time.time()
     base.testingBase.__init__(self, cfg)
예제 #3
0
    def __init__(self, cfg):
        self.log = logger.get_logger("WD_Timer_Testing")
        self.log.info(
            "Look at the modbus watchdog to check for false triggers")
        self.config = cfg

        self.total_resets = 0
        self.last_reset = 0.0
        base.testingBase.__init__(self, cfg, "WD_Timer_Testing")
예제 #4
0
    def __init__(self, cfg):
        self.log = logger.get_logger("testingRun")
        self.log.debug("init testing runner")
        self.cfg = cfg
        tests = TEST_NAMES

        if self.cfg.test in tests:
            self.log.info("Running test: \"%s\" from \"%s\""%(self.cfg.test, tests[self.cfg.test].__name__))
            t = tests[self.cfg.test](self.cfg)
            t.run()
        else:
            raise Exception("unknown test specified: %s"%(self.cfg.test))
예제 #5
0
 def __init__(self, cfg):
     self.log = logger.get_logger("WDT_Testing")
     self.log.info(
         "Look at the modbus watchdog to check for false triggers")
     self.config = cfg
     self.data_size = 120
     self.old_value = 0
     self.ping = 0
     self.old_wd = 0
     self.test_elapse = 0.0
     self.sleep_elapse = 0.0
     self.av_test = 0.0
     self.av_sleep = 0.0
     self.total_wd_resets = 0
     base.testingBase.__init__(self, cfg)
예제 #6
0
    def __init__(self, args):
        self.logger = logger.get_logger('modbusClient')
        self.logger.debug("init modbus client")
        self.client = MClient(args.ip_addr)
        self.args = args
        if False is self.client.connect():
            raise Exception("cannot connect to ip address: %s" %
                            (args.ip_addr))

        # list of arg types and their size, by words, not bytes
        self.args_list = {
            'float': {
                'size': 2
            },
            'uint64': {
                'size': 4
            },
            'int64': {
                'size': 4
            },
            'uint32': {
                'size': 2
            },
            'int32': {
                'size': 2
            },
            'uint16': {
                'size': 1
            },
            'int16': {
                'size': 1
            },
            'int8': {
                'size': 1
            },
            'uint8': {
                'size': 1
            },
            'string': {
                'size': 0
            }
        }
예제 #7
0
def testClass(fname):
    log = logger.get_logger("testClassDecorator")
    def rebuild(cls):
        log.debug("class name is %s"%(cls.__name__))
        log.debug("friendly name is %s"%(fname))
        TEST_NAMES[fname] = cls # save the class in the list

        class Wrapper:
            def __init__(self, *args, **kwargs):
                self.wrapped = cls(*args, **kwargs)

            def __getattr__(self, name):
                log.debug('Getting the {} of {}'.format(name, self.wrapped))
                return getattr(self.wrapped, name)

            # demonstration purposes
            #def added(self):
            #    print 'made it here'
            #    return 'blart'

        return Wrapper
    return rebuild
예제 #8
0
# Add the tests and library to the path for execution
p = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(p, 'lib'))
sys.path.append(os.path.join(p, 'tests'))

# import the actual application
import testing_logger as logger
import testing_base as base
import testing_config as config

# import the actual tests. importing the tests adds them to the test list
# see the command line help for more information
import ct_read_test
import wd_read_test
import wd_ping_test
import wd_timer_test
import multi_interval_test
import interval_test

# Don't allow this to be "import"ed
if __name__ == '__main__':
    # intentionally don't trap exceptions here
    # check the python version and abort if it's not 2.7
    if sys.version_info < (2, 7) or sys.version_info > (3, ):
        raise Exception("This program requires python version 2.7")

    cfg = config.testingConfig()
    logger.setup_logger(cfg)
    log = logger.get_logger("main proc")
    base.testingRun(cfg)
예제 #9
0
 def __init__(self, cfg, name='test'):
     self.log = logger.get_logger('testingBase.'+name)
     self.log.debug("test base init")
     self.config = cfg
     self.client = client.modbusClient(self.config)
     self.ping = 0
예제 #10
0
 def __init__(self, cfg):
     self.log = logger.get_logger("CT_Testing")
     self.log.info("testing the actual Current Transformer readings")
     #self.config = cfg
     base.testingBase.__init__(self, cfg)