From: Amit Bawer <abawer(a)redhat.com>
We add tests for path permutations involving xfail secnarios
to stub argument parsing tests. Also adding missing API tests.
Once we apply all patches involving the new path converter, we
expect all of them to pass with no fails in both python versions.
---
tests/python_test.py | 82 ++++++++++++++++++++++++++++++++------------
1 file changed, 61 insertions(+), 21 deletions(-)
diff --git a/tests/python_test.py b/tests/python_test.py
index 926a0f0..5218435 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -517,64 +517,81 @@ def raises_sanlock_errno(expected_errno=errno.ECONNREFUSED):
yield
assert e.value.errno == expected_errno
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_rem_lockspace_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_rem_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno():
- sanlock.rem_lockspace(name, 1, "ls_path", 0)
+ sanlock.rem_lockspace(name, 1, path, 0)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_add_lockspace_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_add_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno():
- sanlock.add_lockspace(name, 1, "ls_path", 0)
+ sanlock.add_lockspace(name, 1, path, 0)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_write_lockspace_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_write_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno():
- sanlock.write_lockspace(name, "ls_path")
+ sanlock.write_lockspace(name, path)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_write_resource_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_write_resource_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
with raises_sanlock_errno():
- sanlock.write_resource(name, b"res_name", [("disk_path",0)])
+ sanlock.write_resource(name, b"res_name", disks)
with raises_sanlock_errno():
- sanlock.write_resource(b"ls_name", name, [("disk_path",0)])
+ sanlock.write_resource(b"ls_name", name, disks)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_release_resource_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_release_resource_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
with raises_sanlock_errno():
- sanlock.release(name, b"res_name", [("disk_path",0)])
+ sanlock.release(name, b"res_name", disks)
with raises_sanlock_errno():
- sanlock.release(b"ls_name", name, [("disk_path",0)])
+ sanlock.release(b"ls_name", name, disks)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_read_resource_owners_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_read_resource_owners_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
with raises_sanlock_errno():
- sanlock.read_resource_owners(name, b"res_name",
[("disk_path",0)])
+ sanlock.read_resource_owners(name, b"res_name", disks)
with raises_sanlock_errno():
- sanlock.read_resource_owners(b"ls_name", name,
[("disk_path",0)])
+ sanlock.read_resource_owners(b"ls_name", name, disks)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
def test_get_hosts_parse_args(no_sanlock_daemon, name):
with raises_sanlock_errno():
sanlock.get_hosts(name, 1)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_inq_lockspace_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_inq_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno():
- sanlock.inq_lockspace(name, 1, "path", wait=False)
+ sanlock.inq_lockspace(name, 1, path, wait=False)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
def test_reg_event_parse_args(no_sanlock_daemon, name):
with raises_sanlock_errno():
@@ -592,17 +609,40 @@ def test_set_event_parse_args(no_sanlock_daemon, name):
with raises_sanlock_errno():
sanlock.set_event(name, 1, 1, 1)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_init_lockspace_parse_args(no_sanlock_daemon, name):
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_init_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno(errno.ENODEV):
- sanlock.init_lockspace(name, "path")
+ sanlock.init_lockspace(name, path)
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-def test_init_resource_parse_args(no_sanlock_daemon, name):
- disks = [("path", 0)]
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_init_resource_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
with raises_sanlock_errno(errno.ENOENT):
sanlock.init_resource(b"ls_name", name, disks)
with raises_sanlock_errno(errno.ENOENT):
sanlock.init_resource(name, b"res_name", disks)
+
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_get_alignment_parse_args(no_sanlock_daemon, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ with raises_sanlock_errno(errno.ENOENT):
+ sanlock.get_alignment(path)
+
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_read_lockspace_parse_args(no_sanlock_daemon, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ with raises_sanlock_errno():
+ sanlock.read_lockspace(path)
+
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_read_resource_parse_args(no_sanlock_daemon, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ with raises_sanlock_errno():
+ sanlock.read_resource(path)
+
--
2.17.2