Patch for resource/prerequisite GUI issue
Mark Mitchell
mark at codesourcery.com
Thu Dec 19 05:50:01 UTC 2002
This patch (applied in CVS) causes the GUI to present lists of choices
for prerequisites and resources, rather than requiring the user to
type an appropriate name. This isn't prefect (it won't scale to very
large databases), but it is clearly more usable for small databases,
and still avoids the pop-ups used in QMTest 1.x.
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-12-18 Mark Mitchell <mark at codesourcery.com>
* qm/fields.py (ChoiceField): New class.
* qm/test/test.py (Test.ResourceField): Likewise.
(Test.TestField): Likewise.
(Test.arguments): Use them.
Index: qm/fields.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/fields.py,v
retrieving revision 1.60
diff -c -5 -p -r1.60 fields.py
*** qm/fields.py 1 Dec 2002 20:10:12 -0000 1.60
--- qm/fields.py 19 Dec 2002 05:48:26 -0000
*************** class BooleanField(EnumerationField):
*** 1998,2008 ****
# Construct the base class.
EnumerationField.__init__(self, name, default_value,
["true", "false"], **properties)
!
########################################################################
class TimeField(IntegerField):
"""A field containing a date and time.
--- 1998,2045 ----
# Construct the base class.
EnumerationField.__init__(self, name, default_value,
["true", "false"], **properties)
!
! class ChoiceField(TextField):
! """An 'ChoiceField' allows choosing one of several values.
!
! An 'ChoiceField' is similar to an 'EnumerationField' -- but the
! choices for an 'ChoiceField' are computed dynamically, rather than
! chosen statically."""
!
! def FormatValueAsHtml(self, value, style, name = None):
!
! if style not in ("new", "edit"):
! return qm.fields.TextField.FormatValueAsHtml(self, value,
! style, name)
!
! # For an editable field, give the user a choice of available
! # resources.
! result = "<select"
! if name:
! result += ' name="%s"' % name
! result += ">"
! for r in self.GetItems():
! result += '<option value="%s"' % r
! if r == value:
! result += ' selected="1"'
! result += '>%s</option>' % r
! result += "</select>"
!
! return result
!
!
! def GetItems(self):
! """Return the options from which to choose.
!
! returns -- A sequence of strings, each of which will be
! presented as a choice for the user."""
!
! raise NotImplementedError
!
########################################################################
class TimeField(IntegerField):
"""A field containing a date and time.
Index: qm/test/test.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/test.py,v
retrieving revision 1.11
diff -c -5 -p -r1.11 test.py
*** qm/test/test.py 17 Oct 2002 20:38:15 -0000 1.11
--- qm/test/test.py 19 Dec 2002 05:48:26 -0000
*************** class TargetGroupField(qm.fields.TextFie
*** 51,60 ****
--- 51,61 ----
desc = desc + " * " + g + "\n"
return desc
+
class Test(qm.test.runnable.Runnable):
"""A 'Test' is run to check for correct behavior.
A 'Test' performs some check on the system being tested, and
indicates whether the check was successful, or whether the
*************** class Test(qm.test.runnable.Runnable):
*** 107,116 ****
--- 108,140 ----
qm.test.result.Result.ERROR ],
**properties)
+ class ResourceField(qm.fields.ChoiceField):
+ """A 'ResourceField' contains the name of a resource.
+
+ The exact format of the name depends on the test database in use."""
+
+ def GetItems(self):
+
+ database = qm.test.cmdline.get_qmtest().GetDatabase()
+ return database.GetResourceIds()
+
+
+
+ class TestField(qm.fields.ChoiceField):
+ """A 'TestField' contains the name of a resource.
+
+ The exact format of the name depends on the test database in use."""
+
+ def GetItems(self):
+
+ database = qm.test.cmdline.get_qmtest().GetDatabase()
+ return database.GetTestIds()
+
+
arguments = [
TargetGroupField(
name="target_group",
title="Target Group Pattern",
description="""The targets on which this test can run.
*************** class Test(qm.test.runnable.Runnable):
*** 122,132 ****
default_value=".*"
),
qm.fields.SetField(
qm.fields.TupleField(
"prerequisites",
! (qm.fields.TextField(
name = "test_id",
title = "Test",
description = """The name of the prerequisite test.""",
not_empty_text = "true",
),
--- 146,156 ----
default_value=".*"
),
qm.fields.SetField(
qm.fields.TupleField(
"prerequisites",
! (TestField(
name = "test_id",
title = "Test",
description = """The name of the prerequisite test.""",
not_empty_text = "true",
),
*************** class Test(qm.test.runnable.Runnable):
*** 145,155 ****
Every test can depend on other tests. Those tests will be
run before this test. If the prerequisite test does not
have the outcome indicated, this test will not be run.""",
)),
qm.fields.SetField(
! qm.fields.TextField(
name = "resources",
title = "Resources",
description = """Resources on which this test depends.""",
not_empty_text = "true",
)),
--- 169,179 ----
Every test can depend on other tests. Those tests will be
run before this test. If the prerequisite test does not
have the outcome indicated, this test will not be run.""",
)),
qm.fields.SetField(
! ResourceField(
name = "resources",
title = "Resources",
description = """Resources on which this test depends.""",
not_empty_text = "true",
)),
More information about the qmtest
mailing list