Re: [Freeipa-devel] [PATCH] 445 Web UI integration tests: ID range types

2013-08-22 Thread Petr Vobornik

On 08/21/2013 04:30 PM, Ana Krivokapic wrote:

On 08/20/2013 06:19 PM, Nathaniel McCallum wrote:

On Tue, 2013-08-20 at 15:56 +0200, Petr Vobornik wrote:

On 08/19/2013 05:33 PM, Petr Vobornik wrote:

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


New version. Fixes usage of secondary rid for non-trust installation.

A lot of the functions have spaces between the function declaration an
the first line. I don't know how strictly we follow PEP8, but I thought
I'd point it out.

Nathaniel


A general rule is that we _try_ to make any new code PEP8 compliant, as well as
make appropriate fixes when refactoring old code.

Personally, I don't have a problem with a few blank lines. Technically, I don't
think this is a PEP8 violation as blank lines are allowed inside functions.


PEP8 doesn't specify anything about blank lines after function parameter 
list.




The patch works fine and I have no objections to the code, so ACK from me.



Pushed to ipa-3-3 and master.
--
Petr Vobornik

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


Re: [Freeipa-devel] [PATCH] 445 Web UI integration tests: ID range types

2013-08-21 Thread Ana Krivokapic
On 08/20/2013 06:19 PM, Nathaniel McCallum wrote:
 On Tue, 2013-08-20 at 15:56 +0200, Petr Vobornik wrote:
 On 08/19/2013 05:33 PM, Petr Vobornik wrote:
 https://fedorahosted.org/freeipa/ticket/3834

 New version. Fixes usage of secondary rid for non-trust installation.
 A lot of the functions have spaces between the function declaration an
 the first line. I don't know how strictly we follow PEP8, but I thought
 I'd point it out.

 Nathaniel

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

A general rule is that we _try_ to make any new code PEP8 compliant, as well as
make appropriate fixes when refactoring old code.

Personally, I don't have a problem with a few blank lines. Technically, I don't
think this is a PEP8 violation as blank lines are allowed inside functions.

The patch works fine and I have no objections to the code, so ACK from me.

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

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


Re: [Freeipa-devel] [PATCH] 445 Web UI integration tests: ID range types

2013-08-20 Thread Petr Vobornik

On 08/19/2013 05:33 PM, Petr Vobornik wrote:

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



New version. Fixes usage of secondary rid for non-trust installation.

--
Petr Vobornik
From 4f8358e9aa8a4ec2e28d47acd351b556cd10c272 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Fri, 16 Aug 2013 18:18:53 +0200
Subject: [PATCH] Web UI integration tests: ID range types

https://fedorahosted.org/freeipa/ticket/3834
---
 .../test_webui/{test_range.py = task_range.py}|  54 +
 ipatests/test_webui/test_range.py  | 122 +++--
 ipatests/test_webui/test_trust.py  |  93 +---
 ipatests/test_webui/ui_driver.py   |  36 +-
 4 files changed, 212 insertions(+), 93 deletions(-)
 copy ipatests/test_webui/{test_range.py = task_range.py} (66%)

diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/task_range.py
similarity index 66%
copy from ipatests/test_webui/test_range.py
copy to ipatests/test_webui/task_range.py
index 0a7da7e4f3a804c1b4469cac225488b29dcd3138..4775078e7388078ccf4d6a59288388c3dd363ff5 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/task_range.py
@@ -18,16 +18,13 @@
 # along with this program.  If not, see http://www.gnu.org/licenses/.
 
 
-User tests
+Range tasks
 
 
 from ipatests.test_webui.ui_driver import UI_driver
 
-ENTITY = 'idrange'
-PKEY = 'itest-range'
 
-
-class test_range(UI_driver):
+class range_tasks(UI_driver):
 
 def get_shifts(self, idranges=None):
 
@@ -64,27 +61,42 @@ class test_range(UI_driver):
 self.sec_rid_shift = rid_shift + 1000
 self.shift = 0
 
-def get_data(self, pkey, size=50, shift=100):
-self.shift += shift
+def get_sid(self):
+result = self.execute_api_from_ui('trust_find', [], {})
+trusts = result['result']['result']
+sid = None
+if trusts:
+sid = trusts[0]['ipanttrusteddomainsid']
+return sid
+
+def get_data(self, pkey, size=50, add_data=None):
+
+if not add_data:
+add_data = self.get_add_data(pkey, size=size)
+
 data = {
 'pkey': pkey,
-'add': [
-('textbox', 'cn', pkey),
-('textbox', 'ipabaseid', str(self.id_shift + self.shift)),
-('textbox', 'ipaidrangesize', str(size)),
-('textbox', 'ipabaserid', str(self.rid_shift + self.shift)),
-('textbox', 'ipasecondarybaserid', str(self.sec_rid_shift + self.shift)),
-],
+'add': add_data,
 'mod': [
 ('textbox', 'ipaidrangesize', str(size + 1)),
 ],
 }
 return data
 
-def test_crud(self):
-
-Basic CRUD: range
-
-self.init_app()
-self.get_shifts()
-self.basic_crud(ENTITY, self.get_data(PKEY))
+def get_add_data(self, pkey, range_type='ipa-local', size=50, shift=100, sid=None):
+
+self.shift += shift
+add = [
+('textbox', 'cn', pkey),
+('textbox', 'ipabaseid', str(self.id_shift + self.shift)),
+('textbox', 'ipaidrangesize', str(size)),
+('textbox', 'ipabaserid', str(self.rid_shift + self.shift)),
+('radio', 'iparangetype', range_type),
+]
+
+if not sid:
+add.append(('textbox', 'ipasecondarybaserid', str(self.sec_rid_shift + self.shift)))
+if sid:
+add.append(('textbox', 'ipanttrusteddomainsid', sid))
+
+return add
diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py
index 0a7da7e4f3a804c1b4469cac225488b29dcd3138..98c4098a6dba51d9b5d17c36727e3609f5c7ba36 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/test_range.py
@@ -18,68 +18,17 @@
 # along with this program.  If not, see http://www.gnu.org/licenses/.
 
 
-User tests
+Range tests
 
 
-from ipatests.test_webui.ui_driver import UI_driver
+import ipatests.test_webui.test_trust as trust_mod
+from ipatests.test_webui.task_range import range_tasks
 
 ENTITY = 'idrange'
 PKEY = 'itest-range'
 
 
-class test_range(UI_driver):
-
-def get_shifts(self, idranges=None):
-
-if not idranges:
-result = self.execute_api_from_ui('idrange_find', [], {})
-idranges = result['result']['result']
-
-id_shift = 0
-rid_shift = 0
-
-for idrange in idranges:
-size = int(idrange['ipaidrangesize'][0])
-base_id = int(idrange['ipabaseid'][0])
-
-id_end = base_id + size
-rid_end = 0
-
-if 'ipabaserid' in idrange:
-base_rid = int(idrange['ipabaserid'][0])
-rid_end = base_rid + size
-
-if 'ipasecondarybaserid' in idrange:
-secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
-rid_end = max(base_rid, secondary_base_rid) + 

[Freeipa-devel] [PATCH] 445 Web UI integration tests: ID range types

2013-08-19 Thread Petr Vobornik

https://fedorahosted.org/freeipa/ticket/3834
--
Petr Vobornik
From a3d1a12c112bc1cf9b47a6b5fb9a55e817ad47a1 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Fri, 16 Aug 2013 18:18:53 +0200
Subject: [PATCH] Web UI integration tests: ID range types

https://fedorahosted.org/freeipa/ticket/3834
---
 .../test_webui/{test_range.py = task_range.py}|  55 +
 ipatests/test_webui/test_range.py  | 124 -
 ipatests/test_webui/test_trust.py  |  93 +---
 ipatests/test_webui/ui_driver.py   |  36 +-
 4 files changed, 215 insertions(+), 93 deletions(-)
 copy ipatests/test_webui/{test_range.py = task_range.py} (64%)

diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/task_range.py
similarity index 64%
copy from ipatests/test_webui/test_range.py
copy to ipatests/test_webui/task_range.py
index 0a7da7e4f3a804c1b4469cac225488b29dcd3138..2251e7cb9b1f107c7d9669e0788ea15e9c7b21dd 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/task_range.py
@@ -18,16 +18,13 @@
 # along with this program.  If not, see http://www.gnu.org/licenses/.
 
 
-User tests
+Range tasks
 
 
 from ipatests.test_webui.ui_driver import UI_driver
 
-ENTITY = 'idrange'
-PKEY = 'itest-range'
 
-
-class test_range(UI_driver):
+class range_tasks(UI_driver):
 
 def get_shifts(self, idranges=None):
 
@@ -64,27 +61,43 @@ class test_range(UI_driver):
 self.sec_rid_shift = rid_shift + 1000
 self.shift = 0
 
-def get_data(self, pkey, size=50, shift=100):
-self.shift += shift
+def get_sid(self):
+result = self.execute_api_from_ui('trust_find', [], {})
+trusts = result['result']['result']
+sid = None
+if trusts:
+sid = trusts[0]['ipanttrusteddomainsid']
+return sid
+
+def get_data(self, pkey, size=50, add_data=None):
+
+if not add_data:
+sec_rid = self.has_trusts()
+add_data = self.get_add_data(pkey, size=size, sec_rid=sec_rid)
+
 data = {
 'pkey': pkey,
-'add': [
-('textbox', 'cn', pkey),
-('textbox', 'ipabaseid', str(self.id_shift + self.shift)),
-('textbox', 'ipaidrangesize', str(size)),
-('textbox', 'ipabaserid', str(self.rid_shift + self.shift)),
-('textbox', 'ipasecondarybaserid', str(self.sec_rid_shift + self.shift)),
-],
+'add': add_data,
 'mod': [
 ('textbox', 'ipaidrangesize', str(size + 1)),
 ],
 }
 return data
 
-def test_crud(self):
-
-Basic CRUD: range
-
-self.init_app()
-self.get_shifts()
-self.basic_crud(ENTITY, self.get_data(PKEY))
+def get_add_data(self, pkey, range_type='ipa-local', size=50, shift=100, sec_rid=False, sid=None):
+
+self.shift += shift
+add = [
+('textbox', 'cn', pkey),
+('textbox', 'ipabaseid', str(self.id_shift + self.shift)),
+('textbox', 'ipaidrangesize', str(size)),
+('textbox', 'ipabaserid', str(self.rid_shift + self.shift)),
+('radio', 'iparangetype', range_type),
+]
+
+if sec_rid:
+add.append(('textbox', 'ipasecondarybaserid', str(self.sec_rid_shift + self.shift)))
+if sid:
+add.append(('textbox', 'ipanttrusteddomainsid', sid))
+
+return add
diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py
index 0a7da7e4f3a804c1b4469cac225488b29dcd3138..b1c2506a9860cfcca65e9c6b7ba02e456664a51c 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/test_range.py
@@ -18,68 +18,17 @@
 # along with this program.  If not, see http://www.gnu.org/licenses/.
 
 
-User tests
+Range tests
 
 
-from ipatests.test_webui.ui_driver import UI_driver
+import ipatests.test_webui.test_trust as trust_mod
+from ipatests.test_webui.task_range import range_tasks
 
 ENTITY = 'idrange'
 PKEY = 'itest-range'
 
 
-class test_range(UI_driver):
-
-def get_shifts(self, idranges=None):
-
-if not idranges:
-result = self.execute_api_from_ui('idrange_find', [], {})
-idranges = result['result']['result']
-
-id_shift = 0
-rid_shift = 0
-
-for idrange in idranges:
-size = int(idrange['ipaidrangesize'][0])
-base_id = int(idrange['ipabaseid'][0])
-
-id_end = base_id + size
-rid_end = 0
-
-if 'ipabaserid' in idrange:
-base_rid = int(idrange['ipabaserid'][0])
-rid_end = base_rid + size
-
-if 'ipasecondarybaserid' in idrange:
-secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
-rid_end = max(base_rid, secondary_base_rid) + size
-
-if id_shift  id_end:
-