def test_metadata_default(self): cell = PollingCell( target=NoInherentCellSpecimen(), key='value', changes='never') self.assertEqual(cell.metadata().naming, EnumRow( label='value', sort_key='value'))
def test_metadata_explicit(self): cell = PollingCell(target=NoInherentCellSpecimen(), key='value', changes='never', label='foo', description='bar', sort_key='baz') self.assertEqual( cell.metadata().naming, EnumRow(label='foo', description='bar', sort_key='baz'))
def __test_subscription(self, changes): o = NoInherentCellSpecimen() cell = PollingCell(o, 'value', changes=changes, interest_tracker=LoopbackInterestTracker()) st = CellSubscriptionTester(cell) o.value = 1 if changes == 'explicit': cell.poll_for_change(specific_cell=True) st.expect_now(1) st.unsubscribe() o.value = 2 st.advance() # check for unwanted callbacks
def __test_subscription(self, changes): o = NoInherentCellSpecimen() cell = PollingCell(o, 'value', changes=changes) st = CellSubscriptionTester(cell) o.value = 1 if changes == 'explicit': cell.poll_for_change(specific_cell=True) st.expect_now(1) st.unsubscribe() o.value = 2 st.advance() # check for unwanted callbacks
def test_metadata_explicit(self): cell = PollingCell( target=NoInherentCellSpecimen(), key='value', changes='never', label='foo', description='bar', sort_key='baz') self.assertEqual(cell.metadata().naming, EnumRow( label='foo', description='bar', sort_key='baz'))
def _install_gain_cell(self, source_ref, rxd_ref, name): def gain_getter(): source = source_ref[0] return 0 if source is None else source.get_gain(name, ch) def gain_setter(value): source = source_ref[0] if source is not None: source.set_gain(float(value), name, ch) rxd = rxd_ref[0] if rxd is not None: # The single gain and individual-stage gain controls have an unspecified relationship to each other. Thus, changing one must poll the other. rxd.state_changed('gain') gain_range = convert_osmosdr_range(source_ref[0].get_gain_range(name, ch), unit=units.dB) # TODO: There should be a type of Cell such that we don't have to setattr but still implement the storage unlike LooseCell setattr(self, 'get_' + name, gain_getter) setattr(self, 'set_' + name, gain_setter) return name, PollingCell(self, name, type=gain_range, writable=True, persists=True, changes='this_setter', label=name)
def test_subscription_never(self): o = NoInherentCellSpecimen() cell = PollingCell(o, 'value', changes='never', interest_tracker=LoopbackInterestTracker()) st = CellSubscriptionTester(cell, interest_tracking=False) o.value = 1 st.advance() # expected no callback even if we lie
def __init__(self, send, root_object, root_url, subscription_context): self.__subscription_context = subscription_context self._send = send self.__root_object = root_object self._cell = PollingCell(self, '_root_object', type=ReferenceT(), changes='never') self._lastSerial = 0 root_registration = _StateStreamObjectRegistration(ssi=self, subscription_context=self.__subscription_context, obj=self._cell, serial=0, url=root_url, refcount=0) self._registered_objs = {self._cell: root_registration} self.__registered_serials = {root_registration.serial: root_registration} self._send_batch = [] self.__batch_delay = None self.__root_url = root_url root_registration.send_initial_value()
def test_repr(self): cell = PollingCell( target=NoInherentCellSpecimen(), key='value', changes='never') self.assertEqual(repr(cell), '<PollingCell <NoInherentCellSpecimen repr>.value>')
def test_subscription_never(self): o = NoInherentCellSpecimen() cell = PollingCell(o, 'value', changes='never') st = CellSubscriptionTester(cell) o.value = 1 st.advance() # expected no callback even if we lie