def test_async_request(self): """Test async request.""" self.assertTrue(page_put_queue.empty()) self.assertNotIn('statistics', self.site.siteinfo) async_request(self.site.siteinfo.get, 'statistics') page_put_queue.join() self.assertIn('statistics', self.site.siteinfo)
def test_async(self): """Test writing to a page.""" global called_back def callback(page, err): global called_back self.assertEqual(page, p) self.assertIsNone(err) called_back = True self.assertTrue(page_put_queue.empty()) called_back = False ts = str(time.time()) p = pywikibot.Page(self.site, 'User:John Vandenberg/async test write') p.text = ts p.save(async=True, callback=callback) page_put_queue.join() p = pywikibot.Page(self.site, 'User:John Vandenberg/async test write') self.assertEqual(p.text, ts) self.assertTrue(called_back)
def test_async(self): """Test writing to a page.""" global called_back def callback(page, err): global called_back self.assertEqual(page, p) self.assertIsNone(err) called_back = True self.assertTrue(page_put_queue.empty()) called_back = False ts = str(time.time()) p = pywikibot.Page(self.site, 'User:John Vandenberg/async test write') p.text = ts p.save(asynchronous=True, callback=callback) page_put_queue.join() p = pywikibot.Page(self.site, 'User:John Vandenberg/async test write') self.assertEqual(p.text, ts) self.assertTrue(called_back)