def test_mock(self): try: os.remove("test") except OSError: pass daemon = Pyro4.Daemon(unixsocket="test") CONFIG_SED = {"name": "sed", "role": "sed", "channel":5, "limits": [-3, 3]} CONFIG_SCANNER = {"name": "scanner", "role": "ebeam", "limits": [[0, 5], [0, 5]]} CONFIG_SEM = {"name": "sem", "role": "sem", "device": "/dev/comedi0", "children": {"detector0": CONFIG_SED, "scanner": CONFIG_SCANNER} } sem = mock.MockComponent(daemon=daemon, _realcls=model.HwComponent, **CONFIG_SEM) dump = pickle.dumps(sem, pickle.HIGHEST_PROTOCOL) # print "dump size is", len(dump) sem_unpickled = pickle.loads(dump) self.assertEqual(len(sem_unpickled.children.value), 2) sem.terminate()
def test_mock(self): try: os.remove("test") except OSError: pass daemon = Pyro4.Daemon(unixsocket="test") CONFIG_SED = { "name": "sed", "role": "sed", "channel": 5, "limits": [-3, 3] } CONFIG_SCANNER = { "name": "scanner", "role": "ebeam", "limits": [[0, 5], [0, 5]] } CONFIG_SEM = { "name": "sem", "role": "sem", "device": "/dev/comedi0", "children": { "detector0": CONFIG_SED, "scanner": CONFIG_SCANNER } } sem = mock.MockComponent(daemon=daemon, _realcls=model.HwComponent, **CONFIG_SEM) dump = pickle.dumps(sem, pickle.HIGHEST_PROTOCOL) # print "dump size is", len(dump) sem_unpickled = pickle.loads(dump) # Warning, we cannot check inside children because it's (now) a VA, # which requires the daemon to be actually running self.assertIsInstance(sem_unpickled.children, model.VigilantAttributeBase) self.assertEqual(sem_unpickled.name, "sem") sem.terminate() daemon.shutdown()