Hi,
first patch extends webui tests with a callback function, and an
assert_disabled function, to check if a field is disabled under certain
conditions.
Second patch extends range tests with this checking functionality
depending on range types.
Thanks
Adam
>From ba58847116ea90e129ba009d00f50337b5eee32e Mon Sep 17 00:00:00 2001
From: Adam Misnyovszki <amisn...@redhat.com>
Date: Tue, 6 May 2014 16:47:35 +0200
Subject: [PATCH] webui tests: callback, assert_disabled feature added

Added a callback feature to webui tests,
to extend functionality. Also added
assert_disabled function to ui_driver, to
check if a field is disabled in the browser.
---
 ipatests/test_webui/ui_driver.py | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 7cfe21ad8985b04fcb296adccf0277a5f02833b9..1f695fb279ace2f47a31bf7e7feebf180bf4e65a 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1000,7 +1000,7 @@ class UI_driver(object):
             key = field[1]
             val = field[2]
 
-            if undo:
+            if undo and not hasattr(key, '__call__'):
                 self.assert_undo_button(key, False, parent)
 
             if widget_type == 'textbox':
@@ -1025,8 +1025,13 @@ class UI_driver(object):
                 self.fill_multivalued(key, val, parent)
             elif widget_type == 'table':
                 self.select_record(val, parent, key)
+            # this meta field specifies a function, to extend functionality of
+            # field checking
+            elif widget_type == 'callback':
+                if hasattr(key, '__call__'):
+                    key(val)
             self.wait()
-            if undo:
+            if undo and not hasattr(key, '__call__'):
                 self.assert_undo_button(key, True, parent)
 
     def validate_fields(self, fields, parent=None):
@@ -1551,6 +1556,19 @@ class UI_driver(object):
         else:
             assert visible, "Element not visible: %s" % selector
 
+    def assert_disabled(self, selector, parent=None, negative=False):
+        """
+        Assert that element defined by selector is disabled
+        """
+        selector += "[disabled]"
+        if not parent:
+            parent = self.get_form()
+        el = self.find(selector, By.CSS_SELECTOR, parent)
+        if negative:
+            assert el is None, "Element not disabled: %s" % selector
+        else:
+            assert el, "Element disabled: %s" % selector
+
     def assert_record(self, pkey, parent=None, table_name=None, negative=False):
         """
         Assert that record is in current search table
-- 
1.9.0

>From 01b00f7a735c8224619460d05ac239d0a42dc94b Mon Sep 17 00:00:00 2001
From: Adam Misnyovszki <amisn...@redhat.com>
Date: Tue, 6 May 2014 16:49:03 +0200
Subject: [PATCH] webui tests: range test extended

Range test extended with checking of disabled
field according to trust types.
---
 ipatests/test_webui/task_range.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ipatests/test_webui/task_range.py b/ipatests/test_webui/task_range.py
index 3b9c84a96be00cbe556c04b7c29028c2b2f21d0c..d46d345f03a2b50730e3107ef6f7c2222da4465c 100644
--- a/ipatests/test_webui/task_range.py
+++ b/ipatests/test_webui/task_range.py
@@ -95,6 +95,7 @@ class range_tasks(UI_driver):
             ('textbox', 'ipaidrangesize', str(size)),
             ('textbox', 'ipabaserid', str(base_rid)),
             ('radio', 'iparangetype', range_type),
+            ('callback', self.check_range_type_mod, range_type)
         ]
 
         if not sid:
@@ -105,3 +106,11 @@ class range_tasks(UI_driver):
             add.append(('textbox', 'ipanttrusteddomainsid', sid))
 
         return add
+
+    def check_range_type_mod(self, range_type):
+        if range_type == 'ipa-local':
+            self.assert_disabled("[name=ipanttrusteddomainsid]")
+            self.assert_disabled("[name=ipasecondarybaserid]", negative=True)
+        elif range_type == 'ipa-ad-trust':
+            self.assert_disabled("[name=ipanttrusteddomainsid]", negative=True)
+            self.assert_disabled("[name=ipasecondarybaserid]")
-- 
1.9.0

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

Reply via email to