class TestDrivers(object): """ Simple test to test the testing functionality (driver) """ def setup_method(self, method): self.client = MockMonitor() self.driver = Driver(self.client) def teardown_method(self, method): self.client.stop() MockMonitor.static_stop() def assertEventCount(self, count): assert count == len(self.client.events) def testCallback(self): l = [] self.driver.add(CallbackEvent(1, lambda: l.append(True))) self.driver.run() assert 1 == len(l) self.assertEventCount(0) # Events don't get passed on callbacks def testInfo(self): self.driver.add(InfoEvent(1, monitors.EventInfo())) self.driver.run() self.assertEventCount(1)
def run(self, args): retries = 5 interval = 3 dropBoxDir = "DropBox" dirImportWait = 60 pathMode = "Follow" sf = omero.util.internal_service_factory(self.communicator(), "root", "system", retries=retries, interval=interval) try: configService = sf.getConfigService() dropBoxBase = configService.getConfigValue("omero.data.dir") dropBoxBase = os.path.join(dropBoxBase, dropBoxDir) finally: sf.destroy() config = None # Satisfies flake8 but needs fixing fsServer = self.communicator().stringToProxy(config.serverIdString) fsServer = monitors.MonitorServerPrx.checkedCast(fsServer.ice_twoway()) identity = self.communicator().stringToIdentity(config.clientIdString) mClient = MockMonitor(dropBoxBase) adapter = self.communicator().createObjectAdapter( config.clientAdapterName) adapter.add(mClient, identity) adapter.activate() mClientProxy = monitors.MonitorClientPrx.checkedCast( adapter.createProxy(identity)) monitorType = monitors.MonitorType.__dict__["Persistent"] eventTypes = [ monitors.EventType.__dict__["Create"], monitors.EventType.__dict__["Modify"] ] pathMode = monitors.PathMode.__dict__[pathMode] serverId = fsServer.createMonitor(monitorType, eventTypes, pathMode, dropBoxBase, list(config.fileTypes), [], mClientProxy, 0.0, True) mClient.setId(serverId) mClient.setServerProxy(fsServer) mClient.setSelfProxy(mClientProxy) mClient.setDirImportWait(dirImportWait) mClient.setMaster(self) fsServer.startMonitor(serverId) self.communicator().waitForShutdown() if mClient is not None: mClient.stop() fsServer.stopMonitor(id) fsServer.destroyMonitor(id)
def run(self, args): retries = 5 interval = 3 dropBoxDir = "DropBox" dirImportWait = 60 pathMode = "Follow" sf = omero.util.internal_service_factory( self.communicator(), "root", "system", retries=retries, interval=interval) try: configService = sf.getConfigService() dropBoxBase = configService.getConfigValue("omero.data.dir") dropBoxBase = os.path.join(dropBoxBase, dropBoxDir) finally: sf.destroy() config = None # Satisfies flake8 but needs fixing fsServer = self.communicator().stringToProxy(config.serverIdString) fsServer = monitors.MonitorServerPrx.checkedCast(fsServer.ice_twoway()) identity = self.communicator().stringToIdentity(config.clientIdString) mClient = MockMonitor(dropBoxBase) adapter = self.communicator().createObjectAdapter( config.clientAdapterName) adapter.add(mClient, identity) adapter.activate() mClientProxy = monitors.MonitorClientPrx.checkedCast( adapter.createProxy(identity)) monitorType = monitors.MonitorType.__dict__["Persistent"] eventTypes = [monitors.EventType.__dict__["Create"], monitors.EventType.__dict__["Modify"]] pathMode = monitors.PathMode.__dict__[pathMode] serverId = fsServer.createMonitor( monitorType, eventTypes, pathMode, dropBoxBase, list(config.fileTypes), [], mClientProxy, 0.0, True) mClient.setId(serverId) mClient.setServerProxy(fsServer) mClient.setSelfProxy(mClientProxy) mClient.setDirImportWait(dirImportWait) mClient.setMaster(self) fsServer.startMonitor(serverId) self.communicator().waitForShutdown() if mClient is not None: mClient.stop() fsServer.stopMonitor(id) fsServer.destroyMonitor(id)