Hi,

this patch simply checks if ipa-join exists in ipa-client folder, if not, skips 
tests relying on it.
Uses nose.plugin.skip.

https://fedorahosted.org/freeipa/ticket/2905

Tomas Babej
From 2f7cb184619fddd40c7d141b42d35892b6cd5aff Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Fri, 27 Jul 2012 06:34:28 -0400
Subject: [PATCH] Adds check for existence of ipa-client/ipa-join executable
 in the tree in test_host_plugin.py

Simply checks if the executable exists, if not, skips the tests relevant to it (every test in class test_host_false_pwd_change).
Uses nose.plugin.skip.

https://fedorahosted.org/freeipa/ticket/2905
---
 tests/test_xmlrpc/test_host_plugin.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py
index 019152586cf129e501875437f97cb358545bd9b7..74a9ce005807c7492b6f6456c413ca6cd354322b 100644
--- a/tests/test_xmlrpc/test_host_plugin.py
+++ b/tests/test_xmlrpc/test_host_plugin.py
@@ -28,6 +28,7 @@ from ipapython import ipautil
 from ipalib import api, errors, x509
 from ipalib.dn import *
 from nose.tools import raises, assert_raises
+from nose.plugins.skip import Skip, SkipTest
 from tests.test_xmlrpc.xmlrpc_test import (Declarative, XMLRPC_test,
     fuzzy_uuid, fuzzy_digits, fuzzy_hash, fuzzy_date, fuzzy_issuer,
     fuzzy_hex)
@@ -755,6 +756,8 @@ class test_host_false_pwd_change(XMLRPC_test):
     [keytabfd, keytabname] = tempfile.mkstemp()
     os.close(keytabfd)
 
+    does_command_exist = os.path.isfile("./"+command)
+
     # auxiliary function for checking whether the join operation has set
     # correct attributes
     def host_joined(self):
@@ -766,6 +769,10 @@ class test_host_false_pwd_change(XMLRPC_test):
         """
         Create a test host and join him into IPA.
         """
+
+        if not self.does_command_exist: 
+            raise SkipTest
+
         # create a test host with bulk enrollment password
         random_pass = api.Command['host_add'](self.fqdn1, random=True, force=True)['result']['randompassword']
 
@@ -791,6 +798,9 @@ class test_host_false_pwd_change(XMLRPC_test):
         """
         Try to change the password of enrolled host with specified password
         """
+        if not self.does_command_exist: 
+            raise SkipTest
+
         api.Command['host_mod'](self.fqdn1, userpassword=self.new_pass)
 
     @raises(errors.ValidationError)
@@ -798,12 +808,18 @@ class test_host_false_pwd_change(XMLRPC_test):
         """
         Try to change the password of enrolled host with random password
         """
+        if not self.does_command_exist: 
+            raise SkipTest
+
         api.Command['host_mod'](self.fqdn1, random=True)
 
     def test_d_cleanup(self):
         """
         Clean up test data
         """
+        if not self.does_command_exist: 
+            raise SkipTest
+
         os.unlink(self.keytabname)
         api.Command['host_del'](self.fqdn1)
         # verify that it's gone
-- 
1.7.11.2

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to