def test_list_archived_only(self): controller.subscribe('test:long1', SubscriptionMode.Monitor(delta=0.01)).wait() controller.subscribe('test:long2', SubscriptionMode.Monitor(delta=0.123)).wait() controller.subscribe('test:long3', SubscriptionMode.Scan(period=123.1) ).wait() time.sleep(5) controller.unsubscribe('test:long1').wait() controller.unsubscribe('test:long2').wait() # still subscribed to test:long3 archived = dict(controller.list_archived(False)) #don't include currently subscribed self.assertItemsEqual(archived.keys(), ['test:long1', 'test:long2'])
def test_list_subscribed_only(self): controller.subscribe('DEFAULT.PV', SubscriptionMode.Monitor(delta=0.01)).wait() controller.subscribe('FOO.PV', SubscriptionMode.Monitor(delta=0.123)).wait() controller.subscribe('BAR.PV', SubscriptionMode.Scan(period=123.1) ).wait() subscribed = dict(controller.list_subscribed()) self.assertItemsEqual(subscribed.keys(), ['BAR.PV', 'DEFAULT.PV', 'FOO.PV']) controller.unsubscribe('FOO.PV').wait() subscribed = dict(controller.list_subscribed()) self.assertItemsEqual(subscribed.keys(), ['BAR.PV', 'DEFAULT.PV']) # yet 'FOO.PV' is still present in the archive arched = dict(controller.list_archived(False)) self.assertItemsEqual(arched.keys(), ['FOO.PV'])
def test_list_and_get_pvs(self): monitor_mode = SubscriptionMode.Monitor(delta=0.01) scan_mode = SubscriptionMode.Scan(period=1) now_ts = time.time() * 1e6 num_pvs = len(self.pvs) half = num_pvs // 2 monitored_pvs = self.pvs[:half] scanned_pvs = self.pvs[half:] futures = [ controller.subscribe(pv, monitor_mode) for pv in monitored_pvs ] futures += [ controller.subscribe(pv, scan_mode) for pv in scanned_pvs ] [ fut.wait() for fut in futures ] time.sleep(5) pvs_dict = dict(controller.list_archived()) for pv in self.pvs: self.assertIn(pv, pvs_dict) self.assertEqual( pvs_dict[pv].name, pv ) if pv in monitored_pvs: self.assertEqual( pvs_dict[pv].mode.mode, monitor_mode.name ) if pv in scanned_pvs: self.assertEqual( pvs_dict[pv].mode.mode,scan_mode.name ) self.assertAlmostEqual(now_ts, pvs_dict[pv].since, delta=10e6) scanpvs = dict(controller.list_by_mode(scan_mode.name)) for pv in scanpvs: self.assertEqual( scanpvs[pv].mode.mode, scan_mode.name) monitorpvs = dict(controller.list_by_mode(monitor_mode.name)) for pv in monitorpvs: self.assertEqual( monitorpvs[pv].mode.mode, monitor_mode.name)
def get(self): self.win(dict(controller.list_archived()))