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 test_element_get_before_and_after_poll(self): self.setUpForBulkData() self.queue.insert_tail(make_bytes_msg(b'ab')) gotten = self.cell.get() self.assertEqual(gotten, []) st = CellSubscriptionTester(self.cell, delta=True) st.advance() self.assertEqual(self.cell.get(), [ BulkDataElement(data=b'a', info=(1001, )), BulkDataElement(data=b'b', info=(1001, )) ]) self.assertEqual(gotten, []) # not mutating list
def test_subscription(self): st = CellSubscriptionTester(self.vc) self.lc.set(1) st.expect_now(2) self.delta = 10 self.vc.changed_transform() self.assertEqual(1, self.lc.get()) st.expect_now(11) st.unsubscribe() self.lc.set(2) st.advance()
def test_subscription(self): st = CellSubscriptionTester(self.lc) self.lc.set(1) st.expect_now(1) st.unsubscribe() self.lc.set(2) st.advance() # check for unwanted callbacks
def test_string_delta_subscriber(self): self.setUpForUnicodeString() st = CellSubscriptionTester(self.cell, delta=True) self.queue.insert_tail(make_bytes_msg('abç'.encode('utf-8'))) st.expect_now('abç', kind='append') st.unsubscribe() self.queue.insert_tail(make_bytes_msg(b'ignored')) st.advance()
def test_subscription_this_setter(self): o = ValueAndBlockSpecimen() st = CellSubscriptionTester(o.state()['value']) o.set_value(1) st.expect_now(1) st.unsubscribe() o.set_value(2) st.advance() # check for unwanted callbacks
def test_string_delta_subscriber(self): self.setUpForUnicodeString() st = CellSubscriptionTester(self.cell, delta=True) yield self.inject_bytes('abç'.encode('utf-8')) st.expect_now('abç', kind='append') st.unsubscribe() yield self.inject_bytes(b'ignored') st.advance()
def test_subscription(self): o = BlockCellSpecimen(self.obj_value) st = CellSubscriptionTester(o.state()['block']) new = ExportedState() o.replace_block(new) st.expect_now(new) st.unsubscribe() o.replace_block(self.obj_value) st.advance() # check for unwanted callbacks
def __test_subscription(self, changes): o = NoInherentCellSpecimen() cell = Cell(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_element_plain_subscriber(self): self.setUpForBulkData() st = CellSubscriptionTester(self.cell, delta=False) self.queue.insert_tail(make_bytes_msg(b'ab')) st.expect_now([ BulkDataElement(data=b'a', info=(1001, )), BulkDataElement(data=b'b', info=(1001, )) ], kind='value') st.unsubscribe() self.queue.insert_tail(make_bytes_msg(b'ignored')) st.advance()
def test_element_plain_subscriber(self): self.setUpForBulkData() st = CellSubscriptionTester(self.cell, delta=False) yield self.inject_bytes(b'ab') st.expect_now([ BulkDataElement(data=b'a', info=(1001, )), BulkDataElement(data=b'b', info=(1001, )) ], kind='value') st.unsubscribe() yield self.inject_bytes(b'ignored') st.advance()
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_string_plain_subscriber(self): self.setUpForUnicodeString() st = CellSubscriptionTester(self.cell, delta=False) yield self.inject_bytes('abç'.encode('utf-8')) st.expect_now('abç') yield self.inject_bytes('deƒ'.encode('utf-8')) # TODO: This is not the correct result; it should match get(). # Poller currently does not deal with attaching simple subscribers correctly st.expect_now('deƒ')
def test_string_get(self): self.setUpForUnicodeString() self.queue.insert_tail(make_bytes_msg('abç'.encode('utf-8'))) gotten = self.cell.get() self.assertTrue(isinstance(gotten, unicode)) self.assertEqual(gotten, u'') st = CellSubscriptionTester(self.cell, delta=True) st.advance() gotten = self.cell.get() self.assertTrue(isinstance(gotten, unicode)) self.assertEqual(gotten, 'abç') # now append some more to test the buffer self.queue.insert_tail(make_bytes_msg('deƒ'.encode('utf-8'))) st.advance() self.assertEqual(self.cell.get(), 'abçdeƒ')
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
def test_string_coding_error(self): self.setUpForUnicodeString() self.queue.insert_tail(make_bytes_msg(b'ab\xFF')) st = CellSubscriptionTester(self.cell, delta=True) st.expect_now('ab\uFFFD', kind='append')
def test_subscription_never(self): o = NoInherentCellSpecimen() cell = Cell(o, 'value', changes='never') st = CellSubscriptionTester(cell) o.value = 1 st.advance() # expected no callback even if we lie