Hi,

attached patch provides fix for 2 out of three failing tests in ipatests/test_ipalib/test_frontend.py. Failures were caused by changes related to thin client implementation.


Fix for the third failure will be provided later (after my PTO), as it will be more complicated fix.

Lenka

From 0c98433e0604fd7056899e4aec47f561cbc4b0bb Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Wed, 17 Aug 2016 16:37:29 +0200
Subject: [PATCH] Tests: Fix failing tests in test_ipalib/test_frontend

Some tests in ipatests/test_ipalib/test_frontend.py are failing due to changes
related to thin client implementation. Providing fix for:
  ipa.test_ipalib.test_frontend.test_Attribute.test_init
  ipa.test_ipalib.test_frontend.test_LocalOrRemote.test_run

https://fedorahosted.org/freeipa/ticket/6188
---
 ipalib/frontend.py                    |  2 +-
 ipatests/test_ipalib/test_frontend.py | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 455b222d4d7fcbb65b43c4d8e1ffbbaf3e131d22..554d899d97539ab551abaa9983d68450e86454b1 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -1181,7 +1181,7 @@ class LocalOrRemote(Command):
         When running in a server context, this command is always executed
         locally and the value of ``options['server']`` is ignored.
         """
-        if options['server'] and not self.env.in_server:
+        if options.get('server', False) and not self.env.in_server:
             return self.forward(*args, **options)
         return self.execute(*args, **options)
 
diff --git a/ipatests/test_ipalib/test_frontend.py b/ipatests/test_ipalib/test_frontend.py
index c3dd9104c152dc9e9da774a53e0c6a42b9a89bf8..9ca2475030685dbcda6b4ef3cdeded7bb11e0706 100644
--- a/ipatests/test_ipalib/test_frontend.py
+++ b/ipatests/test_ipalib/test_frontend.py
@@ -35,6 +35,7 @@ from ipalib import frontend, backend, plugable, errors, parameters, config
 from ipalib import output, messages
 from ipalib.parameters import Str
 from ipapython.version import API_VERSION
+from ipalib.plugable import APINameSpace
 
 if six.PY3:
     unicode = str
@@ -862,13 +863,13 @@ class test_LocalOrRemote(ClassChecker):
         api.finalize()
         cmd = api.Command.example
         assert cmd(version=u'2.47') == dict(
-            result=('execute', (None,), dict(version=u'2.47', server=False))
+            result=('execute', (), dict(version=u'2.47'))
         )
         assert cmd(u'var', version=u'2.47') == dict(
-            result=('execute', (u'var',), dict(version=u'2.47', server=False))
+            result=('execute', (u'var',), dict(version=u'2.47'))
         )
         assert cmd(server=True, version=u'2.47') == dict(
-            result=('forward', (None,), dict(version=u'2.47', server=True))
+            result=('forward', (), dict(version=u'2.47', server=True))
         )
         assert cmd(u'var', server=True, version=u'2.47') == dict(
             result=('forward', (u'var',), dict(version=u'2.47', server=True))
@@ -880,13 +881,13 @@ class test_LocalOrRemote(ClassChecker):
         api.finalize()
         cmd = api.Command.example
         assert cmd(version=u'2.47') == dict(
-            result=('execute', (None,), dict(version=u'2.47', server=False))
+            result=('execute', (), dict(version=u'2.47', server=False))
         )
         assert cmd(u'var', version=u'2.47') == dict(
             result=('execute', (u'var',), dict(version=u'2.47', server=False))
         )
         assert cmd(server=True, version=u'2.47') == dict(
-            result=('execute', (None,), dict(version=u'2.47', server=True))
+            result=('execute', (), dict(version=u'2.47', server=True))
         )
         assert cmd(u'var', server=True, version=u'2.47') == dict(
             result=('execute', (u'var',), dict(version=u'2.47', server=True))
@@ -940,7 +941,7 @@ class test_Object(ClassChecker):
         methods_format = 'method_%d'
 
         class FakeAPI(object):
-            Method = NameSpace(
+            Method = APINameSpace(
                 get_attributes(cnt, methods_format)
             )
             def __contains__(self, key):
@@ -1106,7 +1107,7 @@ class test_Attribute(ClassChecker):
         """
         user_obj = 'The user frontend.Object instance'
         class api(object):
-            Object = dict(user=user_obj)
+            Object = {("user", "1"): user_obj}
             @staticmethod
             def is_production_mode():
                 return False
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to