summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-11-17 15:43:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-02-15 14:53:35 +0100
commit4e17c050dac8f2c6e2d278c4c4a27001c8d7d164 (patch)
tree642365808a1ef76fff3899e5c7896ca06f9375ed
parent26577ac05dc33c201c15164bcf19f45393beeca5 (diff)
downloadsssd-4e17c050dac8f2c6e2d278c4c4a27001c8d7d164.tar.gz
sssd-4e17c050dac8f2c6e2d278c4c4a27001c8d7d164.tar.xz
sssd-4e17c050dac8f2c6e2d278c4c4a27001c8d7d164.zip
TESTS: move helper fixtures to back up and restore a file to a utility module
The fixtures will be useful for tests that set up and restore a user and group database. While it would be possible to import them already, the functions were previously used in a test and importing from a test seems a bit like a hack. Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/tests/intg/Makefile.am1
-rw-r--r--src/tests/intg/ent_test.py14
-rw-r--r--src/tests/intg/util.py14
3 files changed, 15 insertions, 14 deletions
diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
index e81e5ee95..90e0f3080 100644
--- a/src/tests/intg/Makefile.am
+++ b/src/tests/intg/Makefile.am
@@ -1,5 +1,6 @@
dist_noinst_DATA = \
config.py.m4 \
+ util.py \
sssd_id.py \
sssd_ldb.py \
sssd_netgroup.py \
diff --git a/src/tests/intg/ent_test.py b/src/tests/intg/ent_test.py
index 598930324..6b240ae96 100644
--- a/src/tests/intg/ent_test.py
+++ b/src/tests/intg/ent_test.py
@@ -19,25 +19,11 @@
import re
import os
import io
-import shutil
import pytest
import ent
from util import *
-def backup_envvar_file(name):
- path = os.environ[name]
- backup_path = path + ".bak"
- shutil.copyfile(path, backup_path)
- return path
-
-
-def restore_envvar_file(name):
- path = os.environ[name]
- backup_path = path + ".bak"
- os.rename(backup_path, path)
-
-
@pytest.fixture(scope="module")
def passwd_path(request):
name = "NSS_WRAPPER_PASSWD"
diff --git a/src/tests/intg/util.py b/src/tests/intg/util.py
index 66ec0baa1..2b40311bd 100644
--- a/src/tests/intg/util.py
+++ b/src/tests/intg/util.py
@@ -21,6 +21,7 @@ import re
import os
import subprocess
import config
+import shutil
UNINDENT_RE = re.compile("^ +", re.MULTILINE)
@@ -64,3 +65,16 @@ def first_dir(*args):
for arg in args:
if os.path.isdir(arg):
return arg
+
+
+def backup_envvar_file(name):
+ path = os.environ[name]
+ backup_path = path + ".bak"
+ shutil.copyfile(path, backup_path)
+ return path
+
+
+def restore_envvar_file(name):
+ path = os.environ[name]
+ backup_path = path + ".bak"
+ os.rename(backup_path, path)