Edgewall Software

Ticket #1106: rename_functional_tests.diff

File rename_functional_tests.diff, 6.9 KB (added by shookie@…, 3 years ago)

functional test for rename operations, on top of the previous patch

  • trac/admin/tests/console-tests.txt

    diff -Naur -x .svn trac-branchA/trac/admin/tests/console-tests.txt trac-branchB/trac/admin/tests/console-tests.txt
    old new  
    105105 SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, 
    106106 TICKET_EDIT_CC, TICKET_EDIT_DESCRIPTION, TICKET_MODIFY, TICKET_VIEW, 
    107107 TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, 
    108  WIKI_MODIFY, WIKI_VIEW 
     108 WIKI_MODIFY, WIKI_RENAME, WIKI_VIEW 
    109109 
    110110===== test_permission_add_one_action_ok ===== 
    111111 
     
    139139 SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, 
    140140 TICKET_EDIT_CC, TICKET_EDIT_DESCRIPTION, TICKET_MODIFY, TICKET_VIEW, 
    141141 TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, 
    142  WIKI_MODIFY, WIKI_VIEW 
     142 WIKI_MODIFY, WIKI_RENAME, WIKI_VIEW 
    143143 
    144144===== test_permission_add_multiple_actions_ok ===== 
    145145 
     
    174174 SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, 
    175175 TICKET_EDIT_CC, TICKET_EDIT_DESCRIPTION, TICKET_MODIFY, TICKET_VIEW, 
    176176 TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, 
    177  WIKI_MODIFY, WIKI_VIEW 
     177 WIKI_MODIFY, WIKI_RENAME, WIKI_VIEW 
    178178 
    179179===== test_permission_remove_one_action_ok ===== 
    180180 
     
    207207 SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, 
    208208 TICKET_EDIT_CC, TICKET_EDIT_DESCRIPTION, TICKET_MODIFY, TICKET_VIEW, 
    209209 TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, 
    210  WIKI_MODIFY, WIKI_VIEW 
     210 WIKI_MODIFY, WIKI_RENAME, WIKI_VIEW 
    211211 
    212212===== test_permission_remove_multiple_actions_ok ===== 
    213213 
     
    240240 SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, 
    241241 TICKET_EDIT_CC, TICKET_EDIT_DESCRIPTION, TICKET_MODIFY, TICKET_VIEW, 
    242242 TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, 
    243  WIKI_MODIFY, WIKI_VIEW 
     243 WIKI_MODIFY, WIKI_RENAME, WIKI_VIEW 
    244244 
    245245===== test_component_list_ok ===== 
    246246 
  • trac/tests/functional/tester.py

    diff -Naur -x .svn trac-branchA/trac/tests/functional/tester.py trac-branchB/trac/tests/functional/tester.py
    old new  
    183183            tc.formvalue('attachment', 'replace', True) 
    184184        tc.submit() 
    185185        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid) 
     186        return tempfilename 
    186187 
    187188    def clone_ticket(self, ticketid): 
    188189        """Create a clone of the given ticket id using the clone button.""" 
     
    239240        tc.formvalue('attachment', 'description', random_sentence()) 
    240241        tc.submit() 
    241242        tc.url(self.url + '/attachment/wiki/%s/$' % name) 
     243        return tempfilename 
    242244 
    243245    def create_milestone(self, name=None, due=None): 
    244246        """Creates the specified milestone, with a random name if none is 
  • trac/wiki/templates/wiki_view.html

    diff -Naur -x .svn trac-branchA/trac/wiki/templates/wiki_view.html trac-branchB/trac/wiki/templates/wiki_view.html
    old new  
    9494              </py:if> 
    9595            </py:if> 
    9696            <py:if test="page.exists and rename_perm">  
    97                      <form method="get" action="${href.wiki(page.name)}">  
    98                         <div id="rename">  
     97                     <form  id="rename" method="get" action="${href.wiki(page.name)}">  
     98                        <div>  
    9999                          <input type="hidden" name="action" value="rename" />  
    100100                          <input type="submit" value="${_('Rename page')}" />  
    101101                        </div>  
  • trac/wiki/tests/functional.py

    diff -Naur -x .svn trac-branchA/trac/wiki/tests/functional.py trac-branchB/trac/wiki/tests/functional.py
    old new  
    1111        self._tester.attach_file_to_wiki(pagename) 
    1212 
    1313 
     14class TestWikiRename(FunctionalTwillTestCaseSetup): 
     15    def runTest(self): 
     16        """Test for simple wiki rename""" 
     17        # create a new page (with one attachment) 
     18        pagename = random_unique_camel() 
     19        self._tester.create_wiki_page(pagename) 
     20        attachment = self._tester.attach_file_to_wiki(pagename) 
     21        base_url = self._tester.url 
     22        page_url = base_url + "/wiki/" + pagename 
     23         
     24        def click_rename(): 
     25            tc.formvalue('rename', 'action', 'rename') 
     26            tc.submit() 
     27            tc.url(page_url+r'\?action=rename') 
     28            tc.find("New name:") 
     29         
     30        tc.go(page_url) 
     31        tc.find("Rename") 
     32        click_rename() 
     33        # attempt to rename the page to the current page name ... 
     34        tc.formvalue('rename', 'new_name', pagename) 
     35        tc.submit('rename') 
     36        tc.url(page_url) 
     37        #tc.save_html("rename_warning.html") 
     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('rename', '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('rename', 'new_name', newpagename) 
     50        tc.formvalue('rename', '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('rename', 'new_name', newpagename) 
     65        tc.formvalue('rename', '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 
    1474class RegressionTestTicket4812(FunctionalTwillTestCaseSetup): 
    1575    def runTest(self): 
    1676        """Test for regression of http://trac.edgewall.org/ticket/4812""" 
     
    62122        import trac.tests.functional.testcases 
    63123        suite = trac.tests.functional.testcases.functionalSuite() 
    64124    suite.addTest(TestWiki()) 
     125    suite.addTest(TestWikiRename()) 
    65126    suite.addTest(RegressionTestTicket4812()) 
    66127    if has_docutils: 
    67128        suite.addTest(ReStructuredTextWikiTest())