From 6b81d5cbc683238f383bd1396551793c22065b0d Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Tue, 5 May 2015 00:02:02 +0800 Subject: [PATCH] test_pycephfs: Fix tests for pycephfs Signed-off-by: Haomai Wang --- src/test/pybind/test_cephfs.py | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index 3626cf54b392f..add586b5ab664 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -1,56 +1,55 @@ # vim: expandtab smarttab shiftwidth=4 softtabstop=4 -from nose.tools import assert_raises -import cephfs +from nose.tools import assert_raises, assert_equal +import cephfs as libcephfs cephfs = None def setup_module(): global cephfs - cephfs = cephfs.LibCephFS(conffile='') + cephfs = libcephfs.LibCephFS(conffile='') cephfs.mount() def teardown_module(): global cephfs cephfs.shutdown() -def test_mount(): - cephfs.shutdown() - assert_raise(cephfs.LibCephFSStateError, cephfs.statfs) - cephfs.mount() - def test_version(): cephfs.version() def test_statfs(): - stat = cephfs.statfs() + stat = cephfs.statfs('/') assert(len(stat) == 11) def test_syncfs(): - stat = cephfs.syncfs() + stat = cephfs.sync_fs() def test_directory(): cephfs.mkdir("/temp-directory", 0755) cephfs.chdir("/temp-directory") - assert_equal(cephfs.getcwd() == "/temp-directory") + assert_equal(cephfs.getcwd(), "/temp-directory") cephfs.rmdir("/temp-directory") - cephfs.chdir("/temp-directory") - assert_raise(cephfs.ObjectNotFound, cephfs.chdir("/temp-directory")) + assert_raises(libcephfs.ObjectNotFound, cephfs.chdir, "/temp-directory") def test_walk_dir(): + cephfs.chdir("/") dirs = ["dir-1", "dir-2", "dir-3"] for i in dirs: cephfs.mkdir(i, 0755) handler = cephfs.opendir("/") d = cephfs.readdir(handler) + dirs += [".", ".."] while d: assert(d.d_name in dirs) dirs.remove(d.d_name) d = cephfs.readdir(handler) assert(len(dirs) == 0) + dirs = ["/dir-1", "/dir-2", "/dir-3"] + for i in dirs: + cephfs.rmdir(i) cephfs.closedir(handler) def test_xattr(): - assert_raise(cephfs.InvalidValue, cephfs.setxattr, "/", "key", "value", 0) + assert_raises(libcephfs.OperationNotSupported, cephfs.setxattr, "/", "key", "value", 0) cephfs.setxattr("/", "user.key", "value", 0) assert_equal("value", cephfs.getxattr("/", "user.key")) @@ -58,11 +57,13 @@ def test_rename(): cephfs.mkdir("/a", 0755) cephfs.mkdir("/a/b", 0755) cephfs.rename("/a", "/b") - cephfs.stat("/a/b") + cephfs.stat("/b/b") + cephfs.rmdir("/b/b") + cephfs.rmdir("/b") def test_open(): - assert_raise(cephfs.ObjectNotFound, cephfs.open, 'file-1', 'r') - assert_raise(cephfs.ObjectNotFound, cephfs.open, 'file-1', 'r+') + assert_raises(libcephfs.ObjectNotFound, cephfs.open, 'file-1', 'r') + assert_raises(libcephfs.ObjectNotFound, cephfs.open, 'file-1', 'r+') fd = cephfs.open('file-1', 'w') cephfs.close(fd) fd = cephfs.open('file-1', 'r') -- 2.39.5