[PatchDiscussion] darcs patch: Added some functional tests. (and 1 more)

[email protected] (betabug.darcs)
Newsgroups gmane.comp.web.zope.zwiki
Message-ID <20071223104457.C928E1D032C__34720.5191189007$1198406818$gmane$org@briareus.betabug.ch>
Sat Dec 22 20:56:11 EET 2007  [email protected]
  * Added some functional tests.
  These are implemented using zope.testbrowser, that's why they will
  unfortunately only run on Zope 2.10. The tests basically mimic a browser
  going through some page edits. In that way the tests provide a nice 
  high-level walkthrough. They are using doctest syntax and therefore it's 
  easy to add more. For an overview of the syntax, see:
  SOFTWARE_HOME/zope/testbrowser/README.txt

Sat Dec 22 21:12:29 EET 2007  [email protected]
  * Print a note about Functional tests not running <2.10.



New patches:

[Added some functional tests.
[email protected]**20071222185611
 These are implemented using zope.testbrowser, that's why they will
 unfortunately only run on Zope 2.10. The tests basically mimic a browser
 going through some page edits. In that way the tests provide a nice 
 high-level walkthrough. They are using doctest syntax and therefore it's 
 easy to add more. For an overview of the syntax, see:
 SOFTWARE_HOME/zope/testbrowser/README.txt
] {
addfile ./Functional_tests.py
hunk ./Functional_tests.py 1
+"""This is a a functional doctest test. It uses ZopeTestCase and doctest
+syntax. In the test itself, we use zope.testbrowser to test end-to-end
+functionality, including the UI.
+
+One important thing to note: zope.testbrowser is not JavaScript aware! For
+that, you need a real browser. Look at zope.testbrowser.real and Selenium
+if you require "real" browser testing.
+"""
+
+import unittest
+import doctest
+
+
+from Testing import ZopeTestCase
+ZopeTestCase.installProduct('ZCatalog')
+ZopeTestCase.installProduct('ZWiki')
+
+from zope import traversing, component, interface
+from zope.traversing.adapters import DefaultTraversable
+from zope.traversing.interfaces import ITraversable
+from zope.component import provideAdapter
+from zope import interface
+from zope.interface import implements
+
+class TestZWikiFunctional(ZopeTestCase.FunctionalTestCase):
+    """
+    Testing browser paths through ZWiki.
+    """
+    implements(ITraversable)
+
+    def beforeSetUp(self):
+        super(ZopeTestCase.FunctionalTestCase, self).beforeSetUp()
+        component.provideAdapter( \
+                    traversing.adapters.DefaultTraversable, (interface.Interface,),ITraversable)
+
+    def testSomething(self):
+        # This is here, because otherwise beforeSetUp wouldn't be run
+        pass
+
+def test_suite():
+    suite = unittest.makeSuite(TestZWikiFunctional)
+    suite.addTest(ZopeTestCase.FunctionalDocFileSuite(
+            'functional.txt', package='Products.ZWiki',
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | 
+                        doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS))
+    return suite
+
+if __name__ == "__main__":
+    unittest.main(defaultTest='test_suite')
addfile ./functional.txt
hunk ./functional.txt 1
+Set up some functional tests - these will work only in Zope 2.10 :-(
+because in 2.9 Five does not yet have testbrowser apparently.
+
+    >>> folder_url = self.folder.absolute_url()
+
+    >>> from Products.Five.testbrowser import Browser
+    >>> browser = Browser()
+    >>> browser.handleErrors = False
+
+For simplicity's sake, we're running this as manager:
+
+    >>> from Testing.ZopeTestCase import user_name
+    >>> from Testing.ZopeTestCase import user_password
+    >>> user_auth = 'Basic '+user_name+':'+user_password
+    >>> self.setRoles(['Manager'])
+    >>> browser.addHeader('Authorization', user_auth)
+
+Now let's go and install a ZWiki:
+
+    >>> browser.open(folder_url+'/manage_main')
+    >>> browser.isHtml
+    True
+    >>> browser.contents
+    '...ZWiki...'
+
+Can we add a wiki using the "add" menu?
+
+    >>> control = browser.getControl('ZWiki', index=0)
+    >>> control.selected = True
+    >>> submit = browser.getControl(name='submit')
+    >>> submit.click()
+    >>> browser.contents
+    '...The wiki folder id, which will appear in urls...'
+
+We're in the "Add ZWiki" form.
+Fill out the form:
+
+    >>> id = browser.getControl(name='new_id')
+    >>> title = browser.getControl(name='new_title')
+    >>> type = browser.getControl(name='wiki_type', index=0)
+    >>> print type.value
+    ['basic']
+    >>> id.value = 'testwiki'
+    >>> title.value = 'Test Wiki'
+    >>> type.value = ['basic'] # just to be sure
+    >>> submit = browser.getControl('Add wiki')
+
+    >>> submit.click()
+    >>> browser.contents
+    '...This is the front page of...'
+
+So our new wiki is installed! We are viewing the FrontPage.
+
+Next step is to edit the FrontPage:
+
+    >>> editlink = browser.getLink('edit')
+    >>> editlink.click()
+    >>> browser.url
+    '.../FrontPage/editform'
+
+Change the text.
+
+    >>> textarea = browser.getControl(name='text')
+    >>> textarea.value = "Some text here."
+
+Let's look at a preview first:
+
+    >>> submit = browser.getControl('Preview')
+    >>> submit.click()
+    >>> browser.contents
+    '...Some text here...'
+
+Save it:
+
+    >>> submit = browser.getControl('Save')
+    >>> submit.click()
+    >>> browser.contents
+    '...Some text here...'
+
+Let's revert this edit again.
+First have a look at the history page:
+
+    >>> historylink = browser.getLink(url='FrontPage/history')
+    >>> historylink.click()
+    >>> browser.url
+    '.../FrontPage/history'
+    >>> browser.contents
+    '...Edit history for FrontPage...'
+
+There is a Revision 2 here:
+
+    >>> rev2button = browser.getControl('2')
+
+Have to find the button for Revision 1 now.
+
+    >>> rev1button = browser.getControl('1')
+    >>> rev1button.click()
+    >>> browser.url
+    '.../FrontPage/diff?rev=1'
+
+Now just revert to this revision:
+
+    >>> revertbutton = browser.getControl('Revert to this version')
+    >>> revertbutton.click()
+    >>> browser.url
+    '.../FrontPage'
+    >>> browser.contents
+    '...This is the front page of...'
+
+So we came around full circle to our normal FrontPage. While we're at it,
+we might want to add a new page too. Going through the form at the bottom.
+
+    >>> pagename = browser.getControl(name='pagename')
+    >>> pagename.value = 'My First Wiki Page'
+    >>> create = browser.getControl('create')
+    >>> create.click()
+    >>> browser.url
+    '.../FrontPage'
+    >>> browser.contents
+    '...Optional change note...'
+
+Fill in some text etc.
+
+    >>> textarea = browser.getControl(name='text')
+    >>> textarea.value = 'I like me some text here.'
+    >>> logtext = browser.getControl(name='log')
+    >>> logtext.value = 'initial text entered'
+    >>> create = browser.getControl('Create') # capital C here
+    >>> create.click()
+    >>> browser.url
+    '.../MyFirstWikiPage'
+    >>> browser.contents
+    '...I like me some text here...'
+
}

[Print a note about Functional tests not running <2.10.
[email protected]**20071222191229] {
hunk ./Functional_tests.py 18
-from zope import traversing, component, interface
+try:
+    from zope import traversing, component, interface
+except ImportError:
+    print '--------------------------------------------'
+    print 'Functional tests will only run in Zope 2.10+'
+    print '--------------------------------------------'
+    raise
}

Context:

[1017 - clicking create without pagename gives friendlier error now.
[email protected]**20071126180646
 This probably isn't perfect (user has to click the browsers "back"
 button), but I believe it's much, much better than displaying a
 traceback.
] 
[1352 - remove further (last?) hasattr() calls.
[email protected]**20071117150226
 Since these are in dtml or pt code, we replace them with getattr()
 calls, so we don't have to import our safe_hasattr() here. It would
 be nice if Zope had a built in safe_hasattr().
] 
[962 - Show form on issue pages in HTML markup.
[email protected]**20071117144917] 
[1348 - Quote the redirect URL for the "options" page.
[email protected]**20071105195729
 This is ammending "1348 - Setting useroptions now returns to previous page",
 the URL in a POST variable should be properly quoted. It usually works without 
 this, but it's not correct.
] 
[1391 - fixed "Footer 'create' button without page name results in AttributeError"
[email protected]**20071105185015
 In this case the name of the new page is not entered from the initial 
 "footer" form, but only on the edit/create page.
] 
[more coding style notes
Simon Michael <[email protected]>**20071104173259] 
[directory overview & more style notes
Simon Michael <[email protected]>**20071104164649] 
[add a doc file overview to README
Simon Michael <[email protected]>**20071104163944] 
[move/update some old style docs
Simon Michael <[email protected]>**20071104154420] 
[start a developer style guide, with some documentation guidelines
Simon Michael <[email protected]>**20071102174859] 
[clarify that handleEditText permissions check
Simon Michael <[email protected]>**20071028080428] 
[a little whitespace
[email protected]**20071028062937] 
[make linecounts
[email protected]**20071028062925] 
[Recorded rating change.
[email protected]**20071030110512
 We want to update CHANGES incrementally. Attempting to find a form for
 that here, which at the release could be changed quickly to the final
 release CHANGES.
] 
[Update only rating related indexes in catalog.
[email protected]**20071030085420
 We're saving some bytes by updating only the indexes actually
 related to voting. All metadata will unfortunately be updated anyway.
] 
[Switched to OOBTree for recording ratings.
[email protected]**20071030083921
 Dictionaries on persistant objects in the ZODB can only be saved by
 writing all of the object to the ZODB again. Inefficient. We're using
 a BTree now, which will save us some kB writing to disk and also
 reduces the likelyhood of ConflictErrors on the page.
 On accessting the "votes" we check for old votes still being 
 dictionaries, moving them to BTrees on-the-fly. The overhead for this
 is counterbalanced by easier recording of votes, just set the entry
 in the BTree.
] 
[Remove mentions of purple numbers in comments.
[email protected]**20071029174114] 
[oops! not running tests enough. Two typos and one bugfix
[email protected]**20071028022406] 
[create cleanup. All significant methods in Editing have now been reviewed/tightened up.
Simon Michael <[email protected]>**20071028020234] 
[move methods
Simon Michael <[email protected]>**20071028014132] 
[comment cleanup
[email protected]**20071028014019] 
[autoSubscriptionEnabled cleanup
Simon Michael <[email protected]>**20071028011715] 
[append, edit cleanup
[email protected]**20071028011427] 
[handleSubtopicsProperty cleanup
Simon Michael <[email protected]>**20071028010818] 
[handleEditText cleanup
Simon Michael <[email protected]>**20071028010617] 
[delete cleanup, drop unused updatebacklinks argument
Simon Michael <[email protected]>**20071028010321] 
[handleRename cleanup
Simon Michael <[email protected]>**20071028005220] 
[handleEditPageType cleanup
[email protected]**20071028005122] 
[move a method
[email protected]**20071028004655] 
[revert cleanup
[email protected]**20071026162019] 
[setCreatorLike, setLastEditorLike
[email protected]**20071026162005] 
[tests for new expunge methods
[email protected]**20071026160319] 
[clarification
[email protected]**20071026160308] 
[handy new manager methods expungeLastEditor, expungeLastEditorEverywhere; expunge, expungeEditsEverywhereBy cleanup
[email protected]**20071026150936] 
[#1393 Catch ValueError too on importing unknown pagetypes.
[email protected]**20071022074304] 
[PUT cleanup
Simon Michael <[email protected]>**20071019053515] 
[file upload code cleanup
[email protected]**20071018022343] 
[rename cleanup
[email protected]**20071017125051] 
[cleanupText cleanup
[email protected]**20071017123631] 
[clean up subtopicsEnabled
[email protected]**20071016174006] 
[make bare page rendering at the debug prompt work again, cleanup
[email protected]**20071016172335] 
[removed some unused code in ZWikiPage.py
Simon Michael <[email protected]>**20071013190549] 
[Catch only AttributeError for self.DestinationURL().
[email protected]**20071013191137] 
[os.mkdir will raise OSError, removed bare except.
[email protected]**20071013184205] 
[Catch only locale specific errors, no bare except.
[email protected]**20071013183750] 
[Zope version path changed in >=2.9, bare except removed.
[email protected]**20071013171756] 
[notes update
[email protected]**20071010163932] 
[Change content-type of the SomePage/text (or /src) methods to UTF-8.
[email protected]**20071009085748
 Makes the /text view of wiki pages much more usefull for non-ascii languages.
] 
[wording
[email protected]**20071010150624] 
[Catch only AttributeError instead of bare except clause (in old fix for #1137).
[email protected]**20071003184029] 
[Fix test_setupDtmlMethods for sitemap.xml.dtml.
[email protected]**20071003183255] 
[a google sitemap.xml, installed by setupDtmlMethod.. may reduce load from search bots
[email protected]**20070927201735] 
[remove the anti-spam 24 hour indexing delay introduced in 0.41, for better
Simon Michael <[email protected]>**20070925161611
  indexing of actively-edited pages (#1387)
] 
[feedUrl
Simon Michael <[email protected]>**20070924165908] 
[upgrade notes
Simon Michael <[email protected]>**20070920192543] 
[more upgrade notes
Simon Michael <[email protected]>**20070920190255] 
[clean up and add summary & upgrade notes for 0.60
[email protected]**20070920185128] 
[convert recent relnote headings to definition lists like the rest
[email protected]**20070920182235] 
[merge rc notes, add headings
[email protected]**20070920181617] 
[mailin test comment
[email protected]**20070919175328] 
[rename changes_rss to edits_rss (with a backwards compatibility alias) and
[email protected]**20070918152135
 update the docstring. Also, test forwarding to the PatchDiscussion page.
] 
[keep any text/x-darcs-patch part, as well as the first text/plain part of a mailin
[email protected]**20070919060849] 
[fix darcs patch mailin test
[email protected]**20070919055056] 
[test mailin of a darcs patch
[email protected]**20070918164333] 
[1272 - create PageBrain only for Zwiki Pages.
[email protected]**20070917193709
 Since we are now ensuring that there is always a catalog in a Zwiki,
 the method metadataFor() shouldn't be needed any more. But I'm still
 adding this patch (credits and thanks to koegler), in case some code
 hits on it in the time between an upgrade and running the /upgradeAll
 method.
] 
[TAG release-0-60-0
[email protected]**20070915222130] 
Patch bundle hash:
613f0787e30593e403035ce55b7ea720637a844e

--
forwarded from http://zwiki.org/PatchDiscussion#[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.