LGTM
On Sun, Jun 16, 2019 at 11:50 PM Nir Soffer <nirsof(a)gmail.com> wrote:
Add argument parsing tests for sanlock.acquire() and
sanlock.request().
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/python_test.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tests/python_test.py b/tests/python_test.py
index 4320dad..cd8a82f 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -9,10 +9,11 @@ Test sanlock python binding with sanlock daemon.
"""
from __future__ import absolute_import
import errno
import io
+import os
import struct
import time
from contextlib import contextmanager
@@ -641,5 +642,30 @@ def test_read_lockspace_parse_args(no_sanlock_daemon,
filename, encoding):
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)
+
+(a)pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_request_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
+
+ with raises_sanlock_errno():
+ sanlock.request(b"ls_name", name, disks)
+
+ with raises_sanlock_errno():
+ sanlock.request(name, b"res_name", disks)
+
+
+(a)pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+def test_acquire_parse_args(no_sanlock_daemon, name, filename, encoding):
+ path = util.generate_path("/tmp/", filename, encoding)
+ disks = [(path, 0)]
+
+ with raises_sanlock_errno():
+ sanlock.acquire(b"ls_name", name, disks, pid=os.getpid())
+
+ with raises_sanlock_errno():
+ sanlock.acquire(name, b"res_name", disks, pid=os.getpid())
--
2.17.2