summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-16 16:19:55 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-16 16:27:11 +0200
commit83b4939e16fb202b8412f2f77e915916f53a2048 (patch)
tree765858b1012b159aaafe4fdc7cee56a0ffefe720
parentb54707abf4cfe9204ed68b92166cad9e3d2e59ba (diff)
downloadpython-systemd-83b4939e16fb202b8412f2f77e915916f53a2048.tar.gz
tests: add tests for all id128 funcs, including get_machine_app_specific()
-rw-r--r--setup.py3
-rw-r--r--systemd/test/test_id128.py46
2 files changed, 48 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 42d13ee..4eb11db 100644
--- a/setup.py
+++ b/setup.py
@@ -94,7 +94,8 @@ setup (name = 'systemd-python',
py_modules = ['systemd.journal', 'systemd.daemon',
'systemd.test.test_daemon',
'systemd.test.test_journal',
- 'systemd.test.test_login'],
+ 'systemd.test.test_login',
+ 'systemd.test.test_id128'],
ext_modules = [_journal,
_reader,
_daemon,
diff --git a/systemd/test/test_id128.py b/systemd/test/test_id128.py
new file mode 100644
index 0000000..146ec73
--- /dev/null
+++ b/systemd/test/test_id128.py
@@ -0,0 +1,46 @@
+import contextlib
+import errno
+import uuid
+import pytest
+
+from systemd import id128
+
+@contextlib.contextmanager
+def skip_oserror(code):
+ try:
+ yield
+ except (OSError, IOError) as e:
+ if e.errno == code:
+ pytest.skip()
+ raise
+
+
+def test_randomize():
+ u1 = id128.randomize()
+ u2 = id128.randomize()
+ assert u1 != u2
+
+def test_get_machine():
+ u1 = id128.get_machine()
+ u2 = id128.get_machine()
+ assert u1 == u2
+
+def test_get_machine_app_specific():
+ a1 = uuid.uuid1()
+ a2 = uuid.uuid1()
+
+ with skip_oserror(errno.ENOSYS):
+ u1 = id128.get_machine_app_specific(a1)
+
+ u2 = id128.get_machine_app_specific(a2)
+ u3 = id128.get_machine_app_specific(a1)
+ u4 = id128.get_machine_app_specific(a2)
+
+ assert u1 != u2
+ assert u1 == u3
+ assert u2 == u4
+
+def test_get_boot():
+ u1 = id128.get_boot()
+ u2 = id128.get_boot()
+ assert u1 == u2