Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Improved test coverage. Fixed a broken test.
Browse files Browse the repository at this point in the history
  • Loading branch information
strichter committed Jul 2, 2007
1 parent b370143 commit bc92cd5
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 23 deletions.
6 changes: 6 additions & 0 deletions src/z3c/formdemo/addressbook/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ home address:
>>> user.getControl('State').value = 'MA'
>>> user.getControl('ZIP').value = '01754'

You cannot add the same address twice:

>>> user.getControl('Add', index=0).click()
>>> testing.printElement(user, "//div[@class='summary']")
<div class="summary">Address already provided for contact.</div>

When accidently adding another address, ...

>>> user.getControl(name='contact.add.addresses.widgets.addressName:list')\
Expand Down
14 changes: 14 additions & 0 deletions src/z3c/formdemo/calculator/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,17 @@ The entire calculator state can be reset at any time using the clear button:
... user, "//div[@id='current']/span[@class='value']/text()",
... serialize=False)
0

If a non-valid number is entered, it is just replaced by zero:

>>> user.getControl('4').click()
>>> user.getControl('.').click()
>>> user.getControl('.').click()
>>> user.getControl('3').click()

>>> user.getControl('=').click()

>>> testing.printElement(
... user, "//div[@id='current']/span[@class='value']/text()",
... serialize=False)
0
3 changes: 0 additions & 3 deletions src/z3c/formdemo/message/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ def __init__(self, who, when, what):
self.who = who
self.when = when
self.what = what

def __repr__(self):
return '<%s from %r>' %(self.__class__.__name__, self.who)
3 changes: 0 additions & 3 deletions src/z3c/formdemo/questionnaire/questionnaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,3 @@ class Questionnaire(location.Location, persistent.Persistent):
def __init__(self, **kw):
for name, value in kw.items():
setattr(self, name, value)

def __repr__(self):
return '<%s from %r>' %(self.__class__.__name__, self.name)
2 changes: 1 addition & 1 deletion src/z3c/formdemo/spreadsheet/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There is only one screen for this demo. In it you see the candidate
evaluations table:

>>> testing.printElement(user, "//h1")
<h1>Spreadsheet Demo – Candidate Evaluations</h1>
<h1>Spreadsheet Demo ...</h1>

Initially there are no evaluations, so the screen contains little
information. Let's first fill out a few evaluations by clicking on the button
Expand Down
4 changes: 0 additions & 4 deletions src/z3c/formdemo/spreadsheet/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,3 @@ def __init__(self, lastName, firstName, rating=None):
self.lastName = lastName
self.firstName = firstName
self.rating = rating

def __repr__(self):
return '<%s %s %s>' %(
self.__class__.__name__, self.firstName, self.lastName)
4 changes: 2 additions & 2 deletions src/z3c/formdemo/sqlmessage/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ back to the overview:
<a href="showSQLHelloWorld.html?id=0">cool</a>
</td>
<td class="">
<a href="?delete=0">[Delete]</a>
<a href="showAllSQLHelloWorld.html?delete=0">[Delete]</a>
</td>
</tr>

Expand Down Expand Up @@ -183,7 +183,7 @@ Clicking it again, reverses the order:
To delete a contact, you Simply click on the "Delete" link of the
corresponding row:

>>> user.getLink('[Delete]').click()
>>> user.getLink('[Delete]', index=1).click()

The message is now gone from the table:

Expand Down
3 changes: 2 additions & 1 deletion src/z3c/formdemo/sqlmessage/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def getter(self, item, formatter):
class DeleteSQLColumn(column.Column):

def renderCell(self, item, formatter):
return '<a href="?delete=%i">[Delete]</a>' %item.ID
link = '<a href="showAllSQLHelloWorld.html?delete=%i">[Delete]</a>'
return link % item.ID


class HelloWorldOverview(browser.BrowserPagelet):
Expand Down
23 changes: 21 additions & 2 deletions src/z3c/formdemo/wizard/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ out the data of all steps:
So let's now fill out the form and click the next button this time.

>>> user.getControl('First Name').value = 'Stephan'
>>> user.getControl('Last Name').value = 'Richter'

>>> user.getControl('Phone').value = '+1 555 276-3761'
>>> user.getControl('Email').value = 'stephan.richter_(at)_gmail.com'

>>> user.getControl('Next').click()

But we forgot the last name, which means the form does nto successfully submit
and an error message is shown. So we are still at step 1:

>>> testing.printElement(user, "//legend")
<legend>Personal Information</legend>

Filling in the missing required field will allow the action to be successful:

>>> user.getControl('Last Name').value = 'Richter'
>>> user.getControl('Next').click()

You are now forwarded to the second step:

>>> testing.printElement(user, "//legend")
Expand All @@ -81,10 +91,19 @@ stores the data of the current step:

>>> user.getControl('Street').value = '110 Main Street'
>>> user.getControl('Zip').value = '01754'
>>> user.getControl('City').value = 'Maynard'

>>> user.getControl('Previous').click()

But forgetting a required field does not get you to the previous step.

>>> testing.printElement(user, "//legend")
<legend>Address</legend>

Filling out all information causes the action to be successful:

>>> user.getControl('City').value = 'Maynard'
>>> user.getControl('Previous').click()

So back at step 1, we can see that all the personal information is there.

>>> user.getControl('First Name').value
Expand Down
7 changes: 0 additions & 7 deletions src/z3c/formdemo/wizard/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class PersonalInfo(object):
city = FieldProperty(interfaces.IPersonalInfo['city'])
zip = FieldProperty(interfaces.IPersonalInfo['zip'])

def __repr__(self):
return '<%s %s %s>' %(
self.__class__.__name__, self.firstName, self.lastName)


class Employer(object):
zope.interface.implements(interfaces.IEmployerInfo)
Expand All @@ -44,9 +40,6 @@ class Employer(object):
city = FieldProperty(interfaces.IEmployerInfo['city'])
zip = FieldProperty(interfaces.IEmployerInfo['zip'])

def __repr__(self):
return '<%s %s>' %(self.__class__.__name__, self.name)


class Person(PersonalInfo):

Expand Down

0 comments on commit bc92cd5

Please sign in to comment.