Edgewall Software

Ticket #1106: rename_functional_tests.2.diff

File rename_functional_tests.2.diff, 3.8 KB (added by shookie@…, 2 years ago)

the rename functional tests

  • trac/tests/functional/tester.py

    diff --git a/trac/tests/functional/tester.py b/trac/tests/functional/tester.py
    index b983e1b..24a06e5 100755
    a b class FunctionalTester(object): 
    176176            tc.formvalue('attachment', 'replace', True) 
    177177        tc.submit() 
    178178        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid) 
     179        return tempfilename 
    179180 
    180181    def clone_ticket(self, ticketid): 
    181182        """Create a clone of the given ticket id using the clone button.""" 
    class FunctionalTester(object): 
    232233        tc.formvalue('attachment', 'description', random_sentence()) 
    233234        tc.submit() 
    234235        tc.url(self.url + '/attachment/wiki/%s/$' % name) 
     236        return tempfilename 
    235237 
    236238    def create_milestone(self, name=None, due=None): 
    237239        """Creates the specified milestone, with a random name if none is 
  • trac/wiki/tests/functional.py

    diff --git a/trac/wiki/tests/functional.py b/trac/wiki/tests/functional.py
    index bd85ec8..07a290e 100755
    a b class TestWiki(FunctionalTwillTestCaseSetup): 
    1212        self._tester.attach_file_to_wiki(pagename) 
    1313 
    1414 
     15class TestWikiRename(FunctionalTwillTestCaseSetup): 
     16    def runTest(self): 
     17        """Test for simple wiki rename""" 
     18        pagename = random_unique_camel() 
     19        self._tester.create_wiki_page(pagename) 
     20        self._tester.rename_wiki_page(pagename) 
     21        attachment = self._tester.attach_file_to_wiki(pagename) 
     22        base_url = self._tester.url 
     23        page_url = base_url + "/wiki/" + pagename 
     24         
     25        def click_rename(): 
     26            tc.formvalue('rename', 'action', 'rename') 
     27            tc.submit() 
     28            tc.url(page_url+r'\?action=rename') 
     29            tc.find("New name:") 
     30         
     31        tc.go(page_url) 
     32        tc.find("Rename page") 
     33        click_rename() 
     34        # attempt to rename the page to the current page name ...         
     35        tc.formvalue(page_url, 'new_name', 'rename') 
     36        tc.submit('rename') 
     37        tc.url(page_url) 
     38        tc.find("New name must be different from old name.") 
     39        # attempt to rename the page to an existing page name ... 
     40        tc.formvalue(page_url, 'new_name', 'WikiStart') 
     41        tc.submit('rename') 
     42        tc.url(page_url) 
     43        tc.find("Trac Error") 
     44        tc.find("Can't rename to existing WikiStart page") 
     45        # correct rename to new page name (old page replaced by a redirection) 
     46        tc.go(page_url) 
     47        click_rename() 
     48        newpagename = pagename+'Renamed' 
     49        tc.formvalue(page_url, 'new_name', newpagename) 
     50        tc.formvalue(page_url, 'leave_redirection', True) # the default 
     51        tc.submit('rename') 
     52        # check redirection page 
     53        tc.url(page_url) 
     54        tc.find("See.*/wiki/"+newpagename) 
     55        # check whether attachment exists on the new page but not on old page 
     56        tc.go(base_url+'/attachment/wiki/'+newpagename+'/'+attachment) 
     57        tc.notfind("Error: Invalid Attachment") 
     58        tc.go(base_url+'/attachment/wiki/'+pagename+'/'+attachment) 
     59        tc.find("Error: Invalid Attachment") 
     60        # rename again to another new page name (this time, no redirection) 
     61        tc.go(page_url) 
     62        click_rename() 
     63        newpagename = pagename+'RenamedAgain' 
     64        tc.formvalue(page_url, 'new_name', newpagename) 
     65        tc.formvalue(page_url, 'leave_redirection', False) 
     66        tc.submit('rename') 
     67        tc.url(base_url + "/wiki/" + newpagename) 
     68        # this time, the original page is gone 
     69        tc.go(page_url) 
     70        tc.url(page_url) 
     71        tc.find("Describe %s here" % pagename) 
     72         
     73 
     74 
    1575class RegressionTestTicket4812(FunctionalTwillTestCaseSetup): 
    1676    def runTest(self): 
    1777        """Test for regression of http://trac.edgewall.org/ticket/4812"""