summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLenka Doudova <ldoudova@redhat.com>2016-09-01 09:46:17 +0200
committerMartin Basti <mbasti@redhat.com>2016-09-01 14:00:49 +0200
commit72d7193ce226eed0e84420cd78bd87cceaf935a9 (patch)
tree4140e5e7f5615e0e51b5d945503ae630281ce402
parentafcb3bd3c32aa33dcd68cd0a2ca85bda677000a8 (diff)
downloadfreeipa-72d7193ce226eed0e84420cd78bd87cceaf935a9.tar.gz
freeipa-72d7193ce226eed0e84420cd78bd87cceaf935a9.tar.xz
freeipa-72d7193ce226eed0e84420cd78bd87cceaf935a9.zip
Tests: Avoid skipping tests due to missing files
When running test_install/test_updates and test_pkcs10/test_pkcs10 as outoftree, these are skipped with reason 'Unable to find test update files'. For outoftree tests wrong paths are checked for these files. Changing file localization to provide proper test setup. https://fedorahosted.org/freeipa/ticket/6284 Reviewed-By: Martin Basti <mbasti@redhat.com>
-rw-r--r--ipatests/test_install/test_updates.py41
-rw-r--r--ipatests/test_pkcs10/test_pkcs10.py11
2 files changed, 30 insertions, 22 deletions
diff --git a/ipatests/test_install/test_updates.py b/ipatests/test_install/test_updates.py
index b41a7c5d2..3fa2cd7e1 100644
--- a/ipatests/test_install/test_updates.py
+++ b/ipatests/test_install/test_updates.py
@@ -65,11 +65,9 @@ class test_update(unittest.TestCase):
self.updater = LDAPUpdate(dm_password=self.dm_password, sub_dict={})
self.ld = ipaldap.IPAdmin(fqdn)
self.ld.do_simple_bind(bindpw=self.dm_password)
- if ipautil.file_exists("0_reset.update"):
- self.testdir="./"
- elif ipautil.file_exists("ipatests/test_install/0_reset.update"):
- self.testdir= "./ipatests/test_install/"
- else:
+ self.testdir = os.path.abspath(os.path.dirname(__file__))
+ if not ipautil.file_exists(os.path.join(self.testdir,
+ "0_reset.update")):
raise nose.SkipTest("Unable to find test update files")
self.container_dn = DN(self.updater._template_str('cn=test, cn=accounts, $SUFFIX'))
@@ -84,7 +82,8 @@ class test_update(unittest.TestCase):
Reset the updater test data to a known initial state (test_0_reset)
"""
try:
- modified = self.updater.update([self.testdir + "0_reset.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "0_reset.update")])
except errors.NotFound:
# Just means the entry doesn't exist yet
modified = True
@@ -103,7 +102,8 @@ class test_update(unittest.TestCase):
"""
Test the updater with an add directive (test_1_add)
"""
- modified = self.updater.update([self.testdir + "1_add.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "1_add.update")])
self.assertTrue(modified)
@@ -137,7 +137,8 @@ class test_update(unittest.TestCase):
"""
Test the updater when adding an attribute to an existing entry (test_2_update)
"""
- modified = self.updater.update([self.testdir + "2_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "2_update.update")])
self.assertTrue(modified)
entries = self.ld.get_entries(
@@ -150,7 +151,8 @@ class test_update(unittest.TestCase):
"""
Test the updater forcing an attribute to a given value (test_3_update)
"""
- modified = self.updater.update([self.testdir + "3_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "3_update.update")])
self.assertTrue(modified)
entries = self.ld.get_entries(
@@ -163,7 +165,8 @@ class test_update(unittest.TestCase):
"""
Test the updater adding a new value to a single-valued attribute (test_4_update)
"""
- modified = self.updater.update([self.testdir + "4_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "4_update.update")])
self.assertTrue(modified)
entries = self.ld.get_entries(
@@ -176,7 +179,8 @@ class test_update(unittest.TestCase):
"""
Test the updater adding a new value to a multi-valued attribute (test_5_update)
"""
- modified = self.updater.update([self.testdir + "5_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "5_update.update")])
self.assertTrue(modified)
entries = self.ld.get_entries(
@@ -189,7 +193,8 @@ class test_update(unittest.TestCase):
"""
Test the updater removing a value from a multi-valued attribute (test_6_update)
"""
- modified = self.updater.update([self.testdir + "6_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "6_update.update")])
self.assertTrue(modified)
entries = self.ld.get_entries(
@@ -202,7 +207,8 @@ class test_update(unittest.TestCase):
"""
Test the updater removing a non-existent value from a multi-valued attribute (test_6_update_1)
"""
- modified = self.updater.update([self.testdir + "6_update.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "6_update.update")])
self.assertFalse(modified)
entries = self.ld.get_entries(
@@ -216,7 +222,8 @@ class test_update(unittest.TestCase):
Reset the test data to a known initial state (test_7_cleanup)
"""
try:
- modified = self.updater.update([self.testdir + "0_reset.update"])
+ modified = self.updater.update([os.path.join(self.testdir,
+ "0_reset.update")])
except errors.NotFound:
# Just means the entry doesn't exist yet
modified = True
@@ -236,14 +243,16 @@ class test_update(unittest.TestCase):
Test the updater with an unknown keyword (test_8_badsyntax)
"""
with self.assertRaises(BadSyntax):
- modified = self.updater.update([self.testdir + "8_badsyntax.update"])
+ modified = self.updater.update(
+ [os.path.join(self.testdir, "8_badsyntax.update")])
def test_9_badsyntax(self):
"""
Test the updater with an incomplete line (test_9_badsyntax)
"""
with self.assertRaises(BadSyntax):
- modified = self.updater.update([self.testdir + "9_badsyntax.update"])
+ modified = self.updater.update(
+ [os.path.join(self.testdir, "9_badsyntax.update")])
def test_from_dict(self):
"""
diff --git a/ipatests/test_pkcs10/test_pkcs10.py b/ipatests/test_pkcs10/test_pkcs10.py
index 86de3c696..4c5e09d04 100644
--- a/ipatests/test_pkcs10/test_pkcs10.py
+++ b/ipatests/test_pkcs10/test_pkcs10.py
@@ -31,6 +31,7 @@ from ipapython import ipautil
import nss.nss as nss
from nss.error import NSPRError
import pytest
+import os
@pytest.mark.tier0
@@ -41,15 +42,13 @@ class test_update(object):
def setup(self):
nss.nss_init_nodb()
- if ipautil.file_exists("test0.csr"):
- self.testdir="./"
- elif ipautil.file_exists("ipatests/test_pkcs10/test0.csr"):
- self.testdir= "./ipatests/test_pkcs10/"
- else:
+ self.testdir = os.path.abspath(os.path.dirname(__file__))
+ if not ipautil.file_exists(os.path.join(self.testdir,
+ "test0.csr")):
raise nose.SkipTest("Unable to find test update files")
def read_file(self, filename):
- fp = open(self.testdir + filename, "r")
+ fp = open(os.path.join(self.testdir, filename), "r")
data = fp.read()
fp.close()
return data