def test_enqueue_new_element_delta_same_id(self): cursor = LockedCursor(index=123) dg = DeltaGenerator(cursor=cursor) self.assertEqual(123, dg._cursor.index) test_data = "some test data" # Use FakeDeltaGenerator.fake_text cause if we use # DeltaGenerator.text, it calls enqueue_new_element_delta # automatically. Ideally I should unwrap it. fake_dg = FakeDeltaGenerator() def marshall_element(element): fake_dg.fake_text(element, test_data) new_dg = dg._enqueue_new_element_delta(marshall_element, None) self.assertEqual(dg._cursor, new_dg._cursor) msg = self.get_message_from_queue() self.assertEqual(123, msg.metadata.delta_id) self.assertEqual(msg.delta.new_element.text.body, test_data)
def test_enqueue_new_element_delta(self, container): dg = DeltaGenerator(container=container) self.assertEqual(0, dg._cursor.index) self.assertEqual(container, dg._container) test_data = "some test data" # Use FakeDeltaGenerator.fake_text cause if we use # DeltaGenerator.text, it calls enqueue_new_element_delta # automatically. Ideally I should unwrap it. fake_dg = FakeDeltaGenerator() def marshall_element(element): fake_dg.fake_text(element, test_data) new_dg = dg._enqueue_new_element_delta(marshall_element, None) self.assertNotEqual(dg, new_dg) self.assertEqual(1, dg._cursor.index) self.assertEqual(container, new_dg._container) element = self.get_delta_from_queue().new_element self.assertEqual(element.text.body, test_data)
def test_enqueue_new_element_delta_null(self): # Test "Null" Delta generators dg = DeltaGenerator(container=None) enqueue_fn = lambda x: None new_dg = dg._enqueue_new_element_delta(enqueue_fn, None) self.assertEqual(dg, new_dg)