From 9d36ba462c82a52ef41a9e1a3d3e849d8430a129 Mon Sep 17 00:00:00 2001 From: Gian Mario Tagliaretti Date: Sun, 3 Aug 2008 20:11:13 +0000 Subject: Wrap GFile.replace_async and query_info_async with docs and test. svn path=/trunk/; revision=923 --- tests/test_gio.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'tests') diff --git a/tests/test_gio.py b/tests/test_gio.py index d96d9aa..c321076 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -111,6 +111,49 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testReplaceAsync(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback, None, True, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testReplaceAsyncNoargs(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback) + + loop = glib.MainLoop() + loop.run() + def testReadAsyncError(self): self.assertRaises(TypeError, self.file.read_async) self.assertRaises(TypeError, self.file.read_async, "foo", "bar") @@ -169,6 +212,20 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testQueryInfoAsync(self): + def callback(file, result): + try: + info = file.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_name(), "file.txt") + finally: + loop.quit() + + self.file.query_info_async(callback, "standard") + + loop = glib.MainLoop() + loop.run() + def testMountMountable(self): gfile = gio.File('localtest:') def unmount_done(mount, result): -- cgit