Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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()
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
 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
Exemplo n.º 12
0
 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
Exemplo n.º 13
0
 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()
Exemplo n.º 14
0
 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()
Exemplo n.º 15
0
 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
Exemplo n.º 16
0
 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
Exemplo n.º 17
0
    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ƒ')
Exemplo n.º 18
0
    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ƒ')
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 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')
Exemplo n.º 21
0
 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