Example #1
0
 def runTest(self):
     self.tester.login_as(Usernames.product_owner)
     requirement_id = self.tester.create_new_agilo_requirement('My Requirement')
     self.tester.go_to_view_ticket_page(requirement_id)
     self.tester.select_form_for_twill('attachfile', 'attachfilebutton')
     tc.submit('attachfile')
     tc.find('Add Attachment to')
Example #2
0
 def runTest(self):
     self._tester.login_as(Usernames.team_member)
     self._tester.go_to_new_ticket_page(Type.TASK)
     tc.formvalue('propertyform', 'summary', 'Foo Summary')
     tc.submit('preview')
     tc.notfind('Business Value Points')
     tc.notfind('User Story Priority')
Example #3
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/11515
        Show a notice message with new language setting after it is changed.
        """
        from trac.util.translation import has_babel, get_available_locales
        from pkg_resources import resource_exists, resource_filename

        if not has_babel:
            return
        if not resource_exists("trac", "locale"):
            return
        locale_dir = resource_filename("trac", "locale")
        from babel.support import Translations

        string = "Your preferences have been saved."
        translated = None
        for second_locale in get_available_locales():
            tx = Translations.load(locale_dir, second_locale)
            translated = tx.dgettext("messages", string)
            if string != translated:
                break  # the locale has a translation
        else:
            return

        try:
            self._tester.go_to_preferences("Language")
            tc.formvalue("userprefs", "language", second_locale)
            tc.submit()
            tc.find(re.escape(translated))
        finally:
            tc.formvalue("userprefs", "language", "")  # revert to default
            tc.submit()
            tc.find("Your preferences have been saved")
Example #4
0
 def runTest(self):
     team_name = 'team_for_capacity_saving'
     member_name = 'Team member_name'
     sprint_name = 'capacity_saving_sprint'
     
     self._tester.login_as(Usernames.admin)
     self._tester.create_new_team(team_name)
     self._tester.add_member_to_team(team_name, member_name)
     sprint_start = now()
     self._tester.create_sprint_via_admin(sprint_name, start=sprint_start, team=team_name)
     
     # having tasks with remaining time which were not assigned to a specific
     # user triggered another bug on the team page.
     attributes = dict(sprint=sprint_name, remaining_time='12')
     self._tester.create_new_agilo_task('Not assigned Task', **attributes)
     
     self._tester.login_as(Usernames.scrum_master)
     self._tester.go_to_team_page(team_name, sprint_name)
     team_page_url = tc.get_browser().get_url()
     
     day_ordinal = (sprint_start + timedelta(days=3)).toordinal()
     input_name = 'ts_%s_%d' % (member_name, day_ordinal)
     tc.formvalue('team_capacity_form', input_name, '2')
     tc.submit('save')
     tc.code(200)
     tc.url(team_page_url)
Example #5
0
 def runTest(self):
     self._tester.login_as(Usernames.admin)
     # get page for editing requirement ticket type
     page_url = self._tester.url + '/admin/agilo/types/requirement'
     tc.go(page_url)
     tc.url(page_url)
     tc.code(200)
     tc.find('requirement')
     tc.find('Alias:')
     
     # test default field
     tc.find('name="fields" value="businessvalue" checked="checked"')
     
     # change alias and fields and save
     tc.formvalue('modcomp', 'fields', '+priority')
     tc.formvalue('modcomp', 'fields', '-businessvalue')
     tc.formvalue('modcomp', 'fields', '-milestone')
     tc.formvalue('modcomp', 'fields', '-keywords')
     tc.submit('save')
     
     # redirects to list page, now only the priority should be selected
     tc.find('<td class="fields">[\n ]*Priority<br />[\n ]*</td>')
     
     tc.go(page_url)
     # We must ensure that these fields are available for later tests.
     tc.formvalue('modcomp', 'fields', '+businessvalue')
     tc.formvalue('modcomp', 'fields', '+milestone')
     tc.submit('save')
 def runTest(self):
     self._tester.login_as(Usernames.admin)
     page_url = self._tester.url + '/admin/agilo/fields'
     tc.go(page_url)
     tc.formvalue('addcf', 'name', 'ä')
     tc.submit('add')
     assert 'Only alphanumeric characters allowed for custom field' in tc.show()
Example #7
0
    def runTest(self):
        """Admin modify priority details"""
        name = "DetailPriority"
        # Create a priority
        self._tester.create_priority(name + '1')

        # Modify the details of the priority
        priority_url = self._tester.url + "/admin/ticket/priority"
        tc.go(priority_url)
        tc.url(priority_url + '$')
        tc.follow(name + '1')
        tc.url(priority_url + '/' + name + '1')
        tc.formvalue('edit', 'name', name + '2')
        tc.submit('save')
        tc.url(priority_url + '$')

        # Cancel more modifications
        tc.go(priority_url)
        tc.follow(name)
        tc.formvalue('edit', 'name', name + '3')
        tc.submit('cancel')
        tc.url(priority_url + '$')

        # Verify that only the correct modifications show up
        tc.notfind(name + '1')
        tc.find(name + '2')
        tc.notfind(name + '3')
Example #8
0
 def runTest(self):
     """Set preferences for syntax highlighting."""
     self._tester.go_to_preferences("Syntax Highlighting")
     tc.find('<option value="trac" selected="selected">')
     tc.formvalue('userprefs', 'style', 'Emacs')
     tc.submit()
     tc.find('<option value="emacs" selected="selected">')
Example #9
0
    def runTest(self):
        """Set default handler from the Basic Settings page."""

        # Confirm default value.
        self._tester.go_to_admin("Basic Settings")
        tc.find(r'<option selected="selected" value="WikiModule">'
                r'WikiModule</option>')
        tc.go(self._tester.url)
        tc.find("Welcome to Trac")

        # Set to another valid default handler.
        self._tester.go_to_admin("Basic Settings")
        tc.formvalue('modbasic', 'default_handler', 'TimelineModule')
        tc.submit()
        tc.find("Your changes have been saved.")
        tc.find(r'<option selected="selected" value="TimelineModule">'
                r'TimelineModule</option>')
        tc.go(self._tester.url)
        tc.find(r'<h1>Timeline</h1>')

        # Set to valid disabled default handler.
        try:
            self._testenv.set_config('components',
                                     'trac.timeline.web_ui.TimelineModule',
                                     'disabled')
            self._tester.go_to_admin("Basic Settings")
            tc.find(r'<option value="TimelineModule">TimelineModule</option>')
            tc.find(r'<span class="hint">TimelineModule is not a valid '
                    r'IRequestHandler or is not enabled.</span>')
            tc.go(self._tester.url)
            tc.find(r'<h1>Configuration Error</h1>')
            tc.find(r'Cannot find an implementation of the '
                    r'<code>IRequestHandler</code> interface named '
                    r'<code>TimelineModule</code>')
        finally:
            self._testenv.remove_config('components',
                                        'trac.timeline.web_ui.timelinemodule')

        # Set to invalid default handler.
        try:
            self._testenv.set_config('trac', 'default_handler',
                                     'BatchModifyModule')
            self._tester.go_to_admin("Basic Settings")
            tc.find(r'<option value="BatchModifyModule">BatchModifyModule'
                    r'</option>')
            tc.find(r'<span class="hint">BatchModifyModule is not a valid '
                    r'IRequestHandler or is not enabled.</span>')
            tc.formvalue('modbasic', 'default_handler', 'BatchModifyModule')
            tc.submit()  # Invalid value should not be replaced on submit
            tc.find(r'<option value="BatchModifyModule">BatchModifyModule'
                    r'</option>')
            tc.find(r'<span class="hint">BatchModifyModule is not a valid '
                    r'IRequestHandler or is not enabled.</span>')
            tc.go(self._tester.url)
            tc.find(r'<h1>Configuration Error</h1>')
            tc.find(r'<code>BatchModifyModule</code> is not a valid default '
                    r'handler.')
        finally:
            self._testenv.set_config('trac', 'default_handler', 'WikiModule')
Example #10
0
 def _test_adding_a_backlog(self, page_url, backlog_name):
     tc.go(page_url)
     tc.url(page_url)
     tc.fv('addbacklog', 'name', backlog_name)
     tc.submit('add')
     # we're at the edit page
     backlog_url = page_url + '/' + backlog_name
     tc.url(backlog_url)
Example #11
0
 def runTest(self):
     """Turn off logging."""
     # For now, we just check that it shows up.
     self._tester.go_to_admin("Logging")
     tc.find('trac.log')
     tc.formvalue('modlog', 'log_type', 'none')
     tc.submit()
     tc.find('selected="selected">None</option')
 def runTest(self):
     self._tester.login_as(Usernames.product_owner)
     ticket_id = self._tester.create_new_agilo_ticket(Type.REQUIREMENT, 'req')
     self._tester.go_to_view_ticket_page(ticket_id)
     new_summary = 'really interesting'
     tc.formvalue('propertyform', 'field_summary', new_summary)
     tc.submit('submit')
     tc.find(new_summary)
Example #13
0
 def runTest(self):
     self._tester.login_as(Usernames.admin)
     # Create the milestone first
     self._tester.create_milestone('milestone2')
     
     # get sprint listing, should be empty
     page_url = self._tester.url + '/admin/agilo/sprints'
     tc.go(page_url)
     tc.url(page_url)
     tc.code(200)
     
     # add new sprint
     sprint_start = normalize_date(now())
     sprint_name = 'Test sprint'
     tc.formvalue('addsprint', 'name', sprint_name)
     tc.formvalue('addsprint', 'start', format_datetime(sprint_start, format='iso8601'))
     tc.formvalue('addsprint', 'duration', '1')
     tc.formvalue('addsprint', 'milestone', 'milestone2')
     tc.submit('add')
     # add redirects to list view, new sprint should be in there
     tc.find(sprint_name)
     # go to detail page
     tc.go("%s/%s" % (page_url, quote(sprint_name)))
     # see if milestone is set correctly
     tc.find('<option selected="selected">\s*milestone2')
     
     # test setting end date, not duration
     tc.formvalue('modcomp', 'description', '[http://www.example.com]')
     tomorrow = sprint_start + timedelta(days=1)
     tc.formvalue('modcomp', 'end', format_datetime(tomorrow, format='iso8601'))
     tc.formvalue('modcomp', 'duration', '')
     tc.submit('save')
     tc.url(page_url)
     
     # duration of the new sprint should be 2
     tc.find('"duration">2</td>')
     
     # --- test invalid values when adding sprint ---
     # no values, should redirect to list view
     tc.formvalue('addsprint', 'name', '')
     tc.submit('add')
     tc.url(page_url)
     
     # invalid date, should throw an error
     tc.formvalue('addsprint', 'name', 'Testsprint 2')
     tc.formvalue('addsprint', 'start', '2008 May 13')
     tc.formvalue('addsprint', 'duration', '1')
     tc.submit('add')
     tc.find('Error: Invalid Date')
     
     # no end date or duration
     tc.go(page_url)
     tc.formvalue('addsprint', 'name', 'Testsprint 2')
     yesterday = now() - timedelta(days=3)
     tc.formvalue('addsprint', 'start', 
                  format_datetime(yesterday, format='iso8601'))
     tc.submit('add')
     tc.url(page_url)
Example #14
0
 def _test_ajax_update_fields(self):
     # test Ajax functionality by clicking "update fields" or 
     # passing the new values as a GET parameter
     tc.fv('modcomp', 'scope', 'milestone')
     tc.submit('preview')
     
     # see if the available and selected fields for this backlog 
     # type are display correctly
     tc.find('<option selected="selected" [^>]*>milestone</option>')
Example #15
0
 def runTest(self):
     """Admin remove component"""
     name = "RemovalComponent"
     self._tester.create_component(name)
     component_url = self._tester.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.formvalue('component_table', 'sel', name)
     tc.submit('remove')
     tc.notfind(name)
Example #16
0
 def runTest(self):
     """Repository with an invalid path is rendered with an error
     message on the repository admin page.
     """
     self._tester.go_to_admin("Repositories")
     tc.formvalue("trac-addrepos", "name", "InvalidRepos")
     tc.formvalue("trac-addrepos", "dir", "/the/invalid/path")
     tc.submit()
     tc.find((u'<span class="missing" title="[^"]*">' u"/the/\u200binvalid/\u200bpath</span>").encode("utf-8"))
Example #17
0
 def runTest(self):
     """Admin create duplicate component"""
     name = "DuplicateComponent"
     self._tester.create_component(name)
     component_url = self._tester.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.formvalue('addcomponent', 'name', name)
     tc.submit()
     tc.notfind(internal_error)
     tc.find('Component .* already exists')
Example #18
0
 def runTest(self):
     """Admin remove version"""
     name = "VersionRemove"
     self._tester.create_version(name)
     version_url = self._tester.url + "/admin/ticket/versions"
     tc.go(version_url)
     tc.formvalue('version_table', 'sel', name)
     tc.submit('remove')
     tc.url(version_url + '$')
     tc.notfind(name)
Example #19
0
 def runTest(self):
     """Remove a user from a permissions group"""
     self._tester.go_to_admin("Permissions")
     tc.find('Manage Permissions')
     authenticated = unicode_to_base64('authenticated')
     somegroup = unicode_to_base64('somegroup')
     tc.find('%s:%s' % (authenticated, somegroup))
     tc.formvalue('revokeform', 'sel', '%s:%s' % (authenticated, somegroup))
     tc.submit()
     tc.notfind('%s:%s' % (authenticated, somegroup))
Example #20
0
 def runTest(self):
     """Create a permissions group"""
     self._tester.go_to_admin("Permissions")
     tc.find('Manage Permissions')
     tc.formvalue('addperm', 'gp_subject', 'somegroup')
     tc.formvalue('addperm', 'action', 'REPORT_CREATE')
     tc.submit()
     somegroup = unicode_to_base64('somegroup')
     REPORT_CREATE = unicode_to_base64('REPORT_CREATE')
     tc.find('%s:%s' % (somegroup, REPORT_CREATE))
Example #21
0
 def runTest(self):
     self._tester.login_as(Usernames.scrum_master)
     t_id = self._tester.create_new_agilo_task('Type should not be set')
     #Now go to edit page and save.
     self._tester.go_to_view_ticket_page(t_id)
     tc.fv('propertyform', 'submit', 'click')
     tc.submit('submit')
     # Now check that in the view page there is not type set to Task
     tc.notfind("<li>\s*<strong>type</strong>\s*set to\s*<em>Task</em>\s*</li>", 
                flags='ims')
Example #22
0
 def runTest(self):
     """Repository with an invalid path is rendered with an error
     message on the repository admin page.
     """
     self._tester.go_to_admin("Repositories")
     tc.formvalue('trac-addrepos', 'name', 'InvalidRepos')
     tc.formvalue('trac-addrepos', 'dir', '/the/invalid/path')
     tc.submit()
     tc.find((u'<span class="missing" title="[^"]*">'
              u'/the/\u200binvalid/\u200bpath</span>').encode('utf-8'))
Example #23
0
 def runTest(self):
     """Setting logging back to normal."""
     # For now, we just check that it shows up.
     self._tester.go_to_admin("Logging")
     tc.find('trac.log')
     tc.formvalue('modlog', 'log_file', 'trac.log')
     tc.formvalue('modlog', 'log_level', 'DEBUG')
     tc.submit()
     tc.find('selected="selected">File</option')
     tc.find('id="log_file".*value="trac.log"')
     tc.find('selected="selected">DEBUG</option>')
Example #24
0
 def runTest(self):
     """Remove a permissions group"""
     self._tester.go_to_admin("Permissions")
     tc.find('Manage Permissions')
     somegroup = unicode_to_base64('somegroup')
     REPORT_CREATE = unicode_to_base64('REPORT_CREATE')
     tc.find('%s:%s' % (somegroup, REPORT_CREATE))
     tc.formvalue('revokeform', 'sel', '%s:%s' % (somegroup, REPORT_CREATE))
     tc.submit()
     tc.notfind('%s:%s' % (somegroup, REPORT_CREATE))
     tc.notfind(somegroup)
Example #25
0
 def runTest(self):
     """Admin create duplicate version"""
     name = "DuplicateVersion"
     self._tester.create_version(name)
     version_admin = self._tester.url + "/admin/ticket/versions"
     tc.go(version_admin)
     tc.url(version_admin)
     tc.formvalue('addversion', 'name', name)
     tc.submit()
     tc.notfind(internal_error)
     tc.find('Version "%s" already exists.' % name)
Example #26
0
 def runTest(self):
     """Admin badly renumber priorities"""
     # Make the first priority the 2nd priority, and leave the 2nd priority
     # as the 2nd priority.
     priority_url = self._tester.url + '/admin/ticket/priority'
     tc.go(priority_url)
     tc.url(priority_url + '$')
     tc.formvalue('enumtable', 'value_1', '2')
     tc.submit('apply')
     tc.url(priority_url + '$')
     tc.find('Order numbers must be unique')
Example #27
0
 def runTest(self):
     tc.go(self.tester.url + '/admin/ticket/milestones/' + unicode_quote(self.milestone_name()))
     new_name = self.milestone_name() + 'Renamed'
     tc.formvalue('modifymilestone', 'name', new_name)
     tc.submit('save')
     tc.code(200)
     # Now we expect that the ticket and the sprint have updated milestone
     ticket_page = self.tester.navigate_to_ticket_page(self.tkt_id)
     self.assert_equals(new_name, ticket_page.milestone())
     self.tester.go_to_sprint_edit_page("SprintFor" + self.milestone_name())
     tc.find('for milestone %s</h1>' % new_name)
Example #28
0
 def runTest(self):
     self._tester.login_as(Usernames.product_owner)
     self._tester.upload_csv_for_import(GOOD_CSV_DATA, 'UTF-8')
     tc.find('<h1>Import Preview</h1>')
     
     # Select one form for twill
     tc.formvalue('cancel_import', 'cancel', '1')
     tc.submit('Cancel')
     
     tc.notfind('<strong>Warning:</strong>')
     tc.find('<h1>Import New Tickets from CSV</h1>')
Example #29
0
 def runTest(self):
     """Test for regression of http://trac.edgewall.org/ticket/5765
     Unable to turn off 'Enable access keys' in Preferences
     """
     self._tester.go_to_preferences("Keyboard Shortcuts")
     tc.formvalue('userprefs', 'accesskeys', True)
     tc.submit()
     tc.find('name="accesskeys".*checked="checked"')
     tc.formvalue('userprefs', 'accesskeys', False)
     tc.submit()
     tc.notfind('name="accesskeys".*checked="checked"')
Example #30
0
 def runTest(self):
     self._tester.login_as(Usernames.product_owner)
     story_id = self._tester.create_new_agilo_userstory('as a product owner...')
     self._tester.assign_ticket_to(story_id, Usernames.team_member)
     
     self._tester.login_as(Usernames.team_member)
     self._tester.create_referenced_ticket(story_id, Type.TASK, 'we should do that.')
     
     self._tester.login_as(Usernames.product_owner)
     self._tester.go_to_view_ticket_page(story_id)
     tc.formvalue('delete_link', 'cmd', 'submit')
     tc.submit('cmd')
Example #31
0
    def runTest(self):
        """Admin remove milestone"""
        name = "MilestoneRemove"
        self._tester.create_milestone(name)
        tid = self._tester.create_ticket(info={'milestone': name})
        milestone_url = self._tester.url + '/admin/ticket/milestones'

        tc.go(milestone_url)
        tc.formvalue('milestone_table', 'sel', name)
        tc.submit('remove')

        tc.url(milestone_url + '$')
        tc.notfind(name)
        self._tester.go_to_ticket(tid)
        tc.find('<th id="h_milestone" class="missing">'
                '[ \t\n]*Milestone:[ \t\n]*</th>')
        tc.find('<th class="trac-field-milestone">Milestone:</th>[ \t\n]+'
                '<td>[ \t\n]+'
                '<span class="trac-field-deleted">%s</span>'
                '[ \t\n]+</td>' % name)
        tc.find("Milestone deleted")
Example #32
0
    def runTest(self):
        """The table should be hidden and help text shown when there are no
        components defined (#11103)."""
        from trac.ticket import model
        env = self._testenv.get_trac_environment()
        components = list(model.Component.select(env))
        self._tester.go_to_admin()
        tc.follow(r"\bComponents\b")

        try:
            for comp in components:
                tc.formvalue('component_table', 'sel', comp.name)
            tc.submit('remove')
            tc.notfind('<table class="listing" id="complist">')
            tc.find("As long as you don't add any items to the list, this "
                    "field[ \t\n]*will remain completely hidden from the "
                    "user interface.")
        finally:
            for comp in components:
                self._tester.create_component(comp.name, comp.owner,
                                              comp.description)
Example #33
0
 def runTest(self):
     """Test for regression of the timeline fix in r5883
     From Tim:
     the issue was that event.markup was never being output anywhere, so
     you actually have to render the template with a wiki modification
     and see if '(diff)' shows up as the text in a link
     also note that (diff) should _not_ show up for a wiki creation
     """
     pagename = random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.go_to_timeline()
     tc.find(pagename)
     tc.notfind(pagename + '.*diff</a>\\)')
     self._tester.go_to_wiki(pagename)
     tc.submit(formname='modifypage')
     tc.find('Editing ' + pagename)
     tc.formvalue('edit', 'text', random_page())
     tc.formvalue('edit', 'comment', random_sentence())
     tc.submit('save')
     self._tester.go_to_timeline()
     tc.find(pagename + '.*diff</a>\\)')
Example #34
0
 def runTest(self):
     pagename = self._tester.create_wiki_page()
     self._tester.edit_wiki_page(pagename)
     url = self._tester.url
     tc.follow(r"\bHistory\b")
     tc.url(url + r'/wiki/%s\?action=history' % pagename)
     version_link = ('<td class="version">[ \n]*'
                     '<a href="/wiki/%(pagename)s\?version=%%(version)s"'
                     '[ \n]*title="View this version">%%(version)s[ \n]*</a>'
                     % {'pagename': pagename})
     tc.find(version_link % {'version': 1})
     tc.find(version_link % {'version': 2})
     tc.find(r'<th class="comment">Comment</th>')
     tc.formvalue('history', 'old_version', '1')
     tc.formvalue('history', 'version', '2')
     tc.submit()
     tc.url(r'%s/wiki/%s\?action=diff&version=2&old_version=1'
            % (url, pagename))
     tc.find(r'<a href="/wiki/%s\?version=1">Version 1</a>' % pagename)
     tc.find(r'<a href="/wiki/%s\?version=2">Version 2</a>' % pagename)
     tc.find(r'<a href="/wiki/%(name)s">%(name)s</a>' % {'name': pagename})
Example #35
0
    def runTest(self):
        """Admin renumber priorities"""
        valuesRE = re.compile(b'<select name="value_([0-9]+)">', re.M)
        html = b.get_html()
        max_priority = max([int(x) for x in valuesRE.findall(html)])

        name = "RenumberPriority"
        self._testenv.add_priority(name + '1')
        self._testenv.add_priority(name + '2')
        self._tester.go_to_url('/admin/ticket/priority')
        tc.find(name + '1')
        tc.find(name + '2')
        tc.formvalue('enumtable', 'value_%s' % (max_priority + 1),
                     str(max_priority + 2))
        tc.formvalue('enumtable', 'value_%s' % (max_priority + 2),
                     str(max_priority + 1))
        tc.submit('apply')
        priority_url = self._tester.url + '/admin/ticket/priority'
        tc.url(priority_url, regexp=False)
        # Verify that their order has changed.
        tc.find(name + '2.*' + name + '1', 's')
Example #36
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/11355
        Save with no changes should redirect back to the repository listing.
        """
        # Add a repository
        self._tester.go_to_admin("Repositories")
        name = random_unique_camel()
        dir = os.path.join(tempfile.gettempdir(), name.lower())
        tc.formvalue('trac-addrepos', 'name', name)
        tc.formvalue('trac-addrepos', 'dir', dir)
        tc.submit('add_repos')
        tc.find('The repository "%s" has been added.' % name)

        # Save unmodified form and redirect back to listing page
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.submit('save', formname='edit')
        tc.url(self._tester.url + '/admin/versioncontrol/repository')
        tc.find("Your changes have been saved.")

        # Warning is added when repository dir is not an absolute path
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.formvalue('edit', 'dir', os.path.basename(dir))
        tc.submit('save')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.find('The repository directory must be an absolute path.')
Example #37
0
 def runTest(self):
     """Set preferences for admin user"""
     self._tester.go_to_preferences()
     try:
         tc.notfind('Your preferences have been saved.')
         tc.formvalue('userprefs', 'name', ' System Administrator ')
         tc.formvalue('userprefs', 'email', ' [email protected] ')
         tc.submit()
         tc.find('Your preferences have been saved.')
         self._tester.go_to_preferences("Localization")
         tc.formvalue('userprefs', 'tz', 'GMT -10:00')
         tc.submit()
         tc.find('Your preferences have been saved.')
         self._tester.go_to_preferences()
         tc.notfind('Your preferences have been saved.')
         tc.find('value="System Administrator"')
         tc.find(r'value="admin@example\.com"')
         self._tester.go_to_preferences("Localization")
         tc.find('GMT -10:00')
     finally:
         self._tester.go_to_preferences()
         tc.formvalue('userprefs', 'name', '')
         tc.formvalue('userprefs', 'email', '')
         tc.submit()
         tc.find('Your preferences have been saved.')
Example #38
0
 def runTest(self):
     """Test for regression of http://trac.edgewall.org/ticket/11186 alias
     TracError should be raised when repository alias with name already
     exists
     """
     self._tester.go_to_admin()
     tc.follow("\\bRepositories\\b")
     tc.url(self._tester.url + '/admin/versioncontrol/repository')
     word = random_word()
     target = '%s_repos' % word
     name = '%s_alias' % word
     tc.formvalue('trac-addrepos', 'name', target)
     tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % target)
     tc.submit()
     # Jinja2 tc.find('The repository &#34;%s&#34; has been added.' % target)
     tc.find('The repository "%s" has been added.' % target)
     tc.formvalue('trac-addalias', 'name', name)
     tc.formvalue('trac-addalias', 'alias', target)
     tc.submit()
     # Jinja2 tc.find('The alias &#34;%s&#34; has been added.' % name)
     tc.find('The alias "%s" has been added.' % name)
     tc.formvalue('trac-addalias', 'name', name)
     tc.formvalue('trac-addalias', 'alias', target)
     tc.submit()
     tc.find('The alias &#34;%s&#34; already exists.' % name)
     tc.notfind(internal_error)
Example #39
0
    def runTest(self):
        initial_comment = "Initial comment"
        pagename = self._tester.create_wiki_page(comment=initial_comment)
        url = self._tester.url
        tc.follow(r"\bHistory\b")
        history_url = url + r'/wiki/%s\?action=history' % pagename
        tc.url(history_url)

        # Comment edit from history page
        tc.follow(r"\bEdit\b")
        tc.url(url + r'/wiki/%s\?action=edit_comment&version=1' % pagename)
        tc.find("Old comment:[ \t\n]+%s" % initial_comment)
        first_comment_edit = "First comment edit"
        tc.formvalue('edit-comment-form', 'new_comment', first_comment_edit)
        tc.submit()
        tc.url(history_url)
        tc.find(r'<td class="comment">[ \t\n]+%s' % first_comment_edit)

        # Comment edit from diff page
        tc.formvalue('history', 'version', '1')
        tc.submit()
        diff_url = url + r'/wiki/%s\?action=diff&version=1' % pagename
        tc.url(diff_url)
        tc.find(r'<p>[ \t\n]+%s[ \t\n]+</p>' % first_comment_edit)
        tc.follow(r"\bEdit\b")
        tc.url(url +
               r'/wiki/%s\?action=edit_comment&version=1&redirect_to=diff' %
               pagename)
        second_comment_edit = "Second comment edit"
        tc.formvalue('edit-comment-form', 'new_comment', second_comment_edit)
        tc.submit()
        tc.url(diff_url)
        tc.find(r'<p>[ \t\n]+%s[ \t\n]+</p>' % second_comment_edit)
Example #40
0
    def runTest(self):
        initial_comment = "Initial comment"
        pagename = self._tester.create_wiki_page(comment=initial_comment)
        url = self._tester.url
        tc.follow(r"\bHistory\b")
        history_url = url + r'/wiki/%s?action=history' % pagename
        tc.url(history_url, regexp=False)

        # Comment edit from history page
        tc.move_to('#fieldhist tbody tr:first-child')
        tc.follow(r"\bEdit\b")
        tc.url('%s/wiki/%s?action=edit_comment&version=1' % (url, pagename),
               regexp=False)
        tc.find("Old comment:[ \t\n]+%s" % initial_comment)
        first_comment_edit = "First comment edit"
        tc.formvalue('edit-comment-form', 'new_comment', first_comment_edit)
        tc.submit()
        tc.url(history_url, regexp=False)
        tc.find(r'<td class="comment">[ \t\n]+%s' % first_comment_edit)

        # Comment edit from diff page
        tc.formvalue('history', 'version', '1')
        tc.submit(formname='history')
        tc.url('%s/wiki/%s?action=diff&version=1#' % (url, pagename),
               regexp=False)
        tc.find(r'<p>[ \t\n]+%s[ \t\n]+</p>' % first_comment_edit)
        tc.follow(r"\bEdit\b")
        tc.url('%s/wiki/%s?action=edit_comment&redirect_to=diff&version=1' %
               (url, pagename), regexp=False)
        second_comment_edit = "Second comment edit"
        tc.formvalue('edit-comment-form', 'new_comment', second_comment_edit)
        tc.submit()
        tc.url('%s/wiki/%s?action=diff&old_version=0&version=1' %
               (url, pagename), regexp=False)
        tc.find(r'<p>[ \t\n]+%s[ \t\n]+</p>' % second_comment_edit)
Example #41
0
    def runTest(self):
        self._tester.logout()
        self._tester.login('user')
        page_name = self._tester.create_wiki_page()
        permission_policies = \
            self._testenv.get_config('trac', 'permission_policies')
        readonly_checkbox = ('<input type="checkbox" name="readonly" '
                             'id="readonly"/>')
        attach_button = ('<input type="submit" id="attachfilebutton" '
                         'value="Attach.+file"/>')
        try:
            # User without WIKI_ADMIN can't set a page read-only
            tc.submit(formname='modifypage')
            tc.notfind(readonly_checkbox)

            # User with WIKI_ADMIN can set a page read-only
            # and still edit that page
            self._testenv.grant_perm('user', 'WIKI_ADMIN')
            self._tester.go_to_wiki(page_name)
            tc.submit(formname='modifypage')
            tc.find(readonly_checkbox)
            tc.formvalue('edit', 'readonly', True)
            tc.submit('save')
            tc.go(self._tester.url + '/attachment/wiki/' + page_name)
            tc.find(attach_button)
            self._tester.edit_wiki_page(page_name)

            # User without WIKI_ADMIN can't edit a read-only page
            self._testenv.revoke_perm('user', 'WIKI_ADMIN')
            self._tester.go_to_wiki(page_name)
            tc.notfind('<input type="submit" value="Edit this page" />')
            tc.go(self._tester.url + '/attachment/wiki/' + page_name)
            tc.notfind(attach_button)

            # Read-only checkbox is not present when DefaultWikiPolicy
            # is not in the list of active permission policies
            pp_list = [p.strip() for p in permission_policies.split(',')]
            pp_list.remove('DefaultWikiPolicy')
            self._testenv.set_config('trac', 'permission_policies',
                                     ', '.join(pp_list))
            self._testenv.grant_perm('user', 'WIKI_ADMIN')
            self._tester.go_to_wiki(page_name)
            tc.submit(formname='modifypage')
            tc.notfind(readonly_checkbox)
        finally:
            self._testenv.set_config('trac', 'permission_policies',
                                     permission_policies)
            self._testenv.revoke_perm('user', 'WIKI_ADMIN')
            self._tester.logout()
            self._tester.login('admin')
Example #42
0
    def runTest(self):
        """Admin version detail set time"""
        name = "DetailTimeVersion"
        self._tester.create_version(name)
        version_admin = self._tester.url + "/admin/ticket/versions"
        tc.go(version_admin)
        tc.url(version_admin)
        tc.follow(name)

        tc.formvalue('edit', 'time', '')
        tc.submit('save')
        tc.url(version_admin + '$')
        tc.find(name + '(<[^>]*>|\\s)*<[^>]* name="default" value="%s"' % name,
                's')

        # Empty time value is not automatically populated.
        tc.follow(name)
        tc.find('<input type="text" id="releaseddate"[^>]*value=""')
        tc.submit('save', formname="edit")
        tc.url(version_admin + '$')
        tc.find(name + '(<[^>]*>|\\s)*<[^>]* name="default" value="%s"' % name,
                's')
Example #43
0
 def runTest(self):
     """Admin set default version"""
     name = "DefaultVersion"
     self._tester.create_version(name)
     version_url = self._tester.url + "/admin/ticket/versions"
     tc.go(version_url)
     tc.formvalue('version_table', 'default', name)
     tc.submit('apply')
     tc.find('type="radio" name="default" checked="checked" value="%s"' % \
             name)
     # verify it is the default on the newticket page.
     tc.go(self._tester.url + '/newticket')
     tc.find('<option selected="selected" value="%s">%s</option>' %
             (name, name))
     # Test the "Clear default" button
     tc.go(version_url)
     tc.submit('clear', formname='version_table')
     tc.notfind('type="radio" name="default" checked="checked" value=".+"')
     self._tester.create_ticket()
     tc.find('<th class="missing" id="h_version">[ \t\n]+'
             'Version:[ \t\n]+</th>[ \t\n]+'
             '(?!<td headers="h_version">)')
Example #44
0
 def runTest(self):
     """Admin set default component"""
     name = "DefaultComponent"
     self._tester.create_component(name)
     component_url = self._tester.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.formvalue('component_table', 'default', name)
     tc.submit('apply')
     tc.find('type="radio" name="default" checked="checked" value="%s"' % \
             name)
     tc.go(self._tester.url + '/newticket')
     tc.find('<option selected="selected" value="%s">%s</option>' %
             (name, name))
     # Test the "Clear default" button
     self._testenv.set_config('ticket', 'allowed_empty_fields', 'component')
     tc.go(component_url)
     tc.submit('clear', formname='component_table')
     tc.notfind('type="radio" name="default" checked="checked" value=".+"')
     self._tester.create_ticket()
     tc.find('<th class="missing" id="h_component">\s*Component:\s*</th>'
             '\s*<td headers="h_component">\s*</td>')
     self._testenv.remove_config('ticket', 'allowed_empty_fields')
Example #45
0
    def runTest(self):
        plugin_name = self.__class__.__name__
        env = self._testenv.get_trac_environment()
        env.config.set('components', plugin_name + '.*', 'enabled')
        env.config.save()
        create_file(os.path.join(env.plugins_dir, plugin_name + '.py'),
                    _plugin_py)
        self._testenv.restart()

        try:
            self._tester.go_to_front()
            tc.follow("Wiki")
            tc.submit(formname='modifypage')
            tc.submit('save', 'edit')
            tc.url(self._tester.url + '/wiki/WikiStart', regexp=False)
            tc.find("Invalid Wiki page: The page contains invalid markup at"
                    " line <strong>10</strong>.")
            tc.find("The Wiki page field <strong>comment</strong> is invalid:"
                    " The field <strong>comment</strong> cannot be empty.")
        finally:
            env.config.set('components', plugin_name + '.*', 'disabled')
            env.config.save()
Example #46
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/11515
        Show a notice message with new language setting after it is changed.
        """
        from trac.util.translation import Locale, has_babel, \
                                          get_available_locales
        from pkg_resources import resource_exists, resource_filename

        if not has_babel:
            print("SKIP: RegressionTestTicket11515 (Babel not installed)")
            return
        if not resource_exists('trac', 'locale'):
            return
        locale_dir = resource_filename('trac', 'locale')
        from babel.support import Translations
        string = 'Your preferences have been saved.'
        translated = None
        for second_locale_id in get_available_locales():
            tx = Translations.load(locale_dir, second_locale_id)
            translated = tx.dgettext('messages', string)
            if string != translated:
                break  # the locale has a translation
        else:
            print("SKIP: RegressionTestTicket11515 "
                  "(Message catalogs not compiled)")
            return

        try:
            self._tester.go_to_preferences('Localization')
            tc.formvalue('userprefs', 'language', second_locale_id)
            tc.submit()
            tc.find(re.escape(translated))
            tc.find('<option selected="selected" value="%s">'
                    % second_locale_id)
        finally:
            tc.formvalue('userprefs', 'language', '')  # revert to default
            tc.submit()
            tc.find('Your preferences have been saved')
Example #47
0
    def runTest(self):
        """Create a directory tree in the repository"""
        # This should probably use the svn bindings...
        directories = []
        for component in ('component1', 'component2'):
            directories.append(component)
            for subdir in ('branches', 'tags', 'trunk'):
                directories.append('/'.join([component, subdir]))
        commit_message = 'Create component trees.'
        self._testenv.svn_mkdir(directories, commit_message)

        browser_url = self._tester.url + '/browser'
        tc.go(browser_url)
        tc.url(browser_url)
        tc.find('component1')
        tc.find('component2')
        tc.follow('Last Change')
        tc.url(self._tester.url + '/changeset/1/')
        tc.find(commit_message)
        for directory in directories:
            tc.find(directory)
        tc.back()
        tc.follow('Revision Log')
        # (Note that our commit log message is short enough to avoid
        # truncation.)
        tc.find(commit_message)
        tc.follow('Timeline')
        # (Note that our commit log message is short enough to avoid
        # truncation.)
        tc.find(commit_message)
        tc.formvalue('prefs', 'ticket', False)
        tc.formvalue('prefs', 'milestone', False)
        tc.formvalue('prefs', 'wiki', False)
        tc.submit()
        tc.find('by.*admin')
        # (Note that our commit log message is short enough to avoid
        # truncation.)
        tc.find(commit_message)
Example #48
0
    def runTest(self):
        """Admin version detail set time"""
        name = self._testenv.add_version()
        self._tester.go_to_url('/admin/ticket/versions')
        tc.follow(name)

        # Clear value and send ENTER to close the datepicker.
        tc.formvalue('edit', 'time', '')
        tc.send_keys(tc.keys.ESCAPE)  # close datepicker
        tc.wait_for('invisibility_of_element', id='ui-datepicker-div')
        tc.submit('save')
        version_admin = self._tester.url + "/admin/ticket/versions"
        tc.url(version_admin, regexp=False)
        tc.find(name + '(<[^>]*>|\\s)*<[^>]* name="default" value="%s"' % name,
                's')

        # Empty time value is not automatically populated.
        tc.follow(name)
        tc.find('<input type="text" id="releaseddate"[^>]*value=""')
        tc.submit('save', formname="edit")
        tc.url(version_admin, regexp=False)
        tc.find(name + '(<[^>]*>|\\s)*<[^>]* name="default" value="%s"' % name,
                's')
Example #49
0
    def runTest(self):
        """Check persistence of search filters in session (#11292)."""
        filters = ['milestone', 'changeset', 'ticket', 'wiki']

        def setfilters(checked):
            for i, f in enumerate(filters):
                tc.formvalue('fullsearch', f, checked[i])

        def checkfilters(checked):
            for i, f in enumerate(filters):
                is_checked = r'id="%s"[^>]* checked="checked"' % f
                if checked[i]:
                    tc.find(is_checked)
                else:
                    tc.notfind(is_checked)

        self._tester.go_to_front()
        # First sequence:
        tc.follow('^Search')
        seq_a = [True, False, True, False]
        setfilters(seq_a)
        tc.formvalue('fullsearch', 'q', 'anything...')
        tc.submit()
        # In the result page, the filters checkboxes reflect what's
        # been selected
        checkfilters(seq_a)
        # Now, this selection also persists after resetting the search page
        tc.follow('^Search')
        checkfilters(seq_a)
        # Second sequence:
        seq_b = [False, True, False, True]
        setfilters(seq_b)
        tc.formvalue('fullsearch', 'q', 'anything...')
        tc.submit()
        checkfilters(seq_b)
        tc.follow('^Search')
        checkfilters(seq_b)
Example #50
0
    def runTest(self):
        """Admin modify milestone details"""
        name = self._tester.create_milestone()

        milestone_url = self._tester.url + '/admin/ticket/milestones'

        def go_to_milestone_detail():
            tc.go(milestone_url)
            tc.url(milestone_url)
            tc.follow(name)
            tc.url(milestone_url + '/' + name)

        # Modify the details of the milestone
        go_to_milestone_detail()
        tc.formvalue('edit', 'due', True)
        tc.formvalue('edit', 'description', 'Some description.')
        tc.submit('save')
        tc.url(milestone_url)

        # Milestone is not closed
        self._tester.go_to_roadmap()
        tc.find(name)

        # Cancel more modifications and modification are not saved
        go_to_milestone_detail()
        tc.formvalue('edit', 'description', '~~Some other description.~~')
        tc.submit('cancel')
        tc.url(milestone_url)
        self._tester.go_to_roadmap()
        tc.find('Some description.')
        tc.follow(name)
        tc.find('Some description.')

        # Milestone is readonly when user doesn't have MILESTONE_MODIFY
        self._tester.logout()
        self._testenv.grant_perm('user', 'TICKET_ADMIN')
        self._tester.login('user')
        go_to_milestone_detail()
        try:
            tc.find(r'<input[^>]+id="name"[^>]+readonly="readonly"')
            tc.find(r'<input[^>]+id="due"[^>]+disabled="disabled"')
            tc.find(r'<input[^>]+id="duedate"[^>]+readonly="readonly"')
            tc.find(r'<input[^>]+id="completed"[^>]+disabled="disabled"')
            tc.find(r'<input[^>]+id="completeddate"[^>]+readonly="readonly"')
            tc.find(r'<textarea[^>]+id="description"[^>]+readonly="readonly"')
            tc.find(r'<input[^>]+name="save"[^>]+disabled="disabled"')
            tc.submit('cancel', 'edit')
            tc.url(milestone_url)
        finally:
            self._tester.logout()
            self._testenv.revoke_perm('user', 'TICKET_ADMIN')
            self._tester.login('admin')
Example #51
0
    def runTest(self):
        """Delete a wiki page."""
        name = self._tester.create_wiki_page()
        self._tester.go_to_wiki(name)
        tc.formvalue('delete', 'action', 'delete')
        tc.submit()
        tc.notfind("The following attachments will also be deleted:")
        tc.submit('delete', 'delete-confirm')
        tc.find("The page %s has been deleted." % name)
        tc.url(self._tester.url)

        name = self._tester.create_wiki_page()
        filename = self._tester.attach_file_to_wiki(name)
        self._tester.go_to_wiki(name)
        tc.formvalue('delete', 'action', 'delete')
        tc.submit()
        tc.find("The following attachments will also be deleted:")
        tc.find(filename)
        tc.submit('delete', 'delete-confirm')
        tc.find("The page %s has been deleted." % name)
        tc.url(self._tester.url)
Example #52
0
    def runTest(self):
        """Test for regression of https://trac.edgewall.org/ticket/11194
        TracError should be raised when repository with name already exists
        """
        self._tester.go_to_admin()
        tc.follow("\\bRepositories\\b")
        tc.url(self._tester.url + '/admin/versioncontrol/repository',
               regexp=False)

        word = random_word()
        names = ['%s_%d' % (word, n) for n in range(3)]
        tc.formvalue('trac-addrepos', 'name', names[0])
        tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % names[0])
        tc.submit()
        tc.notfind(internal_error)

        tc.formvalue('trac-addrepos', 'name', names[1])
        tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % names[1])
        tc.submit()
        tc.notfind(internal_error)

        tc.follow('\\b' + names[1] + '\\b')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' +
               names[1], regexp=False)
        tc.formvalue('edit', 'name', names[2])
        tc.submit('save')
        tc.notfind(internal_error)
        tc.url(self._tester.url + '/admin/versioncontrol/repository',
               regexp=False)

        tc.follow('\\b' + names[2] + '\\b')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' +
               names[2], regexp=False)
        tc.formvalue('edit', 'name', names[0])
        tc.submit('save')
        tc.find('The repository &#34;%s&#34; already exists.' % names[0])
        tc.notfind(internal_error)
Example #53
0
    def runTest(self):
        """Check basic settings."""
        self._tester.go_to_admin()
        tc.formvalue('modbasic', 'url', 'https://my.example.com/something')
        tc.submit()
        tc.find('https://my.example.com/something')

        try:
            tc.formvalue('modbasic', 'default_dateinfo_format', 'absolute')
            tc.submit()
            tc.find(r'<option selected="selected" value="absolute">')
            tc.formvalue('modbasic', 'default_dateinfo_format', 'relative')
            tc.submit()
            tc.find(r'<option selected="selected" value="relative">')
        finally:
            self._testenv.remove_config('trac', 'default_dateinfo_format')
            self._tester.go_to_admin()
            tc.find(r'<option selected="selected" value="relative">')
            tc.find(r'<option value="absolute">')
Example #54
0
    def runTest(self):
        """Test for regression of https://trac.edgewall.org/ticket/11186 alias
        TracError should be raised when repository alias with name already
        exists
        """
        self._tester.go_to_admin()
        tc.follow("\\bRepositories\\b")
        tc.url(self._tester.url + '/admin/versioncontrol/repository')
        word = random_word()
        target = '%s_repos' % word
        name = '%s_alias' % word
        tc.formvalue('trac-addrepos', 'name', target)
        tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % target)
        tc.submit()
        # Jinja2 tc.find('The repository &#34;%s&#34; has been added.' % target)
        tc.find('The repository "%s" has been added.' % target)

        # Add alias.
        tc.formvalue('trac-addalias', 'name', name)
        tc.formvalue('trac-addalias', 'alias', target)
        tc.submit()
        # Jinja2 tc.find('The alias &#34;%s&#34; has been added.' % name)
        tc.find('The alias "%s" has been added.' % name)

        # sync_per_request checkbox should not be shown on detail page.
        tc.follow(name)
        tc.notfind(
            '<input type="checkbox" name="sync_per_request" value="1"/>')

        # Adding same alias again will raise a TracError.
        tc.follow("\\bRepositories\\b")
        tc.formvalue('trac-addalias', 'name', name)
        tc.formvalue('trac-addalias', 'alias', target)
        tc.submit()
        tc.find('The alias &#34;%s&#34; already exists.' % name)
        tc.notfind(internal_error)
Example #55
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/10957"""

        self._tester.go_to_front()
        try:
            self._tester.logout()

            # Check that page can't be created without WIKI_CREATE
            page_name = random_unique_camel()
            self._tester.go_to_wiki(page_name)
            tc.find("Trac Error")
            tc.find("Page %s not found" % page_name)
            tc.notfind("Create this page")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find(
                "WIKI_CREATE privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

            # Check that page can be created when user has WIKI_CREATE
            self._testenv.grant_perm('anonymous', 'WIKI_CREATE')
            content_v1 = random_sentence()
            self._tester.create_wiki_page(page_name, content_v1)
            tc.find(content_v1)

            # Check that page can't be edited without WIKI_MODIFY
            tc.notfind("Edit this page")
            tc.notfind("Attach file")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find(
                "WIKI_MODIFY privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

            # Check that page can be edited when user has WIKI_MODIFY
            self._testenv.grant_perm('anonymous', 'WIKI_MODIFY')
            self._tester.go_to_wiki(page_name)
            tc.find("Edit this page")
            tc.find("Attach file")
            content_v2 = random_sentence()
            self._tester.edit_wiki_page(page_name, content_v2)
            tc.find(content_v2)

            # Check that page can be reverted to a previous revision
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.find("Revert to this version")
            tc.formvalue('modifypage', 'action', 'edit')
            tc.submit()
            tc.find(content_v1)

            # Check that page can't be reverted without WIKI_MODIFY
            self._tester.edit_wiki_page(page_name)
            self._testenv.revoke_perm('anonymous', 'WIKI_MODIFY')
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.notfind("Revert to this version")
            tc.go(self._tester.url +
                  '/wiki/%s?action=edit&version=1' % page_name)
            tc.find(
                "WIKI_MODIFY privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

        finally:
            # Restore pre-test state.
            self._tester.login('admin')
            self._testenv.revoke_perm('anonymous', 'WIKI_CREATE')
Example #56
0
 def click_rename():
     tc.formvalue('rename', 'action', 'rename')
     tc.submit()
     tc.url(page_url + r'\?action=rename')
     tc.find("New name:")
Example #57
0
    def runTest(self):
        """Test for simple wiki rename"""
        pagename = self._tester.create_wiki_page()
        attachment = self._tester.attach_file_to_wiki(pagename)
        base_url = self._tester.url
        page_url = base_url + "/wiki/" + pagename

        def click_rename():
            tc.formvalue('rename', 'action', 'rename')
            tc.submit()
            tc.url(page_url + r'\?action=rename')
            tc.find("New name:")

        tc.go(page_url)
        tc.find("Rename page")
        click_rename()
        # attempt to give an empty new name
        tc.formvalue('rename-form', 'new_name', '')
        tc.submit('submit')
        tc.url(page_url)
        tc.find("A new name is mandatory for a rename")
        # attempt to rename the page to an invalid page name
        tc.formvalue('rename-form', 'new_name', '../WikiStart')
        tc.submit('submit')
        tc.url(page_url)
        tc.find("The new name is invalid")
        # attempt to rename the page to the current page name
        tc.formvalue('rename-form', 'new_name', pagename)
        tc.submit('submit')
        tc.url(page_url)
        tc.find("The new name must be different from the old name")
        # attempt to rename the page to an existing page name
        tc.formvalue('rename-form', 'new_name', 'WikiStart')
        tc.submit('submit')
        tc.url(page_url)
        tc.find("The page WikiStart already exists")
        # correct rename to new page name (old page replaced by a redirection)
        tc.go(page_url)
        click_rename()
        newpagename = pagename + 'Renamed'
        tc.formvalue('rename-form', 'new_name', newpagename)
        tc.formvalue('rename-form', 'redirect', True)
        tc.submit('submit')
        # check redirection page
        tc.url(page_url)
        tc.find("See.*/wiki/" + newpagename)
        tc.find("The page %s has been renamed to %s." %
                (pagename, newpagename))
        tc.find("The page %s has been recreated with a redirect to %s." %
                (pagename, newpagename))
        # check whether attachment exists on the new page but not on old page
        tc.go(base_url + '/attachment/wiki/' + newpagename + '/' + attachment)
        tc.notfind("Error: Invalid Attachment")
        tc.go(base_url + '/attachment/wiki/' + pagename + '/' + attachment)
        tc.find("Error: Invalid Attachment")
        # rename again to another new page name (this time, no redirection)
        tc.go(page_url)
        click_rename()
        newpagename = pagename + 'RenamedAgain'
        tc.formvalue('rename-form', 'new_name', newpagename)
        tc.formvalue('rename-form', 'redirect', False)
        tc.submit('submit')
        tc.url(base_url + "/wiki/" + newpagename)
        tc.find("The page %s has been renamed to %s." %
                (pagename, newpagename))
        # this time, the original page is gone
        tc.go(page_url)
        tc.url(page_url)
        tc.find("The page %s does not exist" % tag.strong(pagename))
Example #58
0
    def runTest(self):
        """Test for regression of https://trac.edgewall.org/ticket/10772"""
        def find_prop(field, value=None):
            if value and field == 'type':
                tc.find(r'<span class="trac-%(field)s">\s*'
                        r'<a href="/query\?status=!closed&amp;'
                        r'%(field)s=%(value)s">\s*%(value)s\s*</a>\s*</span>' %
                        {
                            'field': field,
                            'value': value
                        })
            elif value and field == 'milestone':
                tc.find(r'<td headers="h_%(field)s">\s*'
                        r'<a class="%(field)s" href="/%(field)s/%(value)s" '
                        r'title=".+">\s*%(value)s\s*</a>\s*</td>' % {
                            'field': field,
                            'value': value
                        })
            elif value:
                tc.find(r'<td headers="h_%(field)s">\s*'
                        r'<a href="/query\?status=!closed&amp;'
                        r'%(field)s=%(value)s">\s*%(value)s\s*</a>\s*</td>' % {
                            'field': field,
                            'value': value
                        })
            else:
                tc.find(r'<td headers="h_%(field)s">\s*</td>' %
                        {'field': field})

        self._testenv.set_config('ticket', 'allowed_empty_fields',
                                 'component, milestone, priority, version')

        try:
            # TODO: use the //Clear default// buttons to clear these values
            self._tester.go_to_admin("Components")
            tc.submit('clear', formname='component_table')
            self._tester.go_to_admin("Milestones")
            tc.submit('clear', formname='milestone_table')
            self._tester.go_to_admin("Versions")
            tc.submit('clear', formname='version_table')
            self._tester.go_to_admin("Priorities")
            tc.formvalue('enumtable', 'default', 'major')
            tc.submit('apply')

            self._tester.create_ticket('ticket summary')

            find_prop('component')
            find_prop('milestone')
            find_prop('priority', 'major')
            find_prop('version')

            self._testenv.set_config('ticket', 'allowed_empty_fields', '')
            self._tester.go_to_admin("Components")
            tc.formvalue('component_table', 'default', 'component2')
            tc.submit('apply')
            self._tester.go_to_admin("Milestones")
            tc.formvalue('milestone_table', 'ticket_default', 'milestone2')
            tc.submit('apply')
            self._tester.go_to_admin("Priorities")
            tc.formvalue('enumtable', 'default', 'minor')
            tc.submit('apply')
            self._tester.go_to_admin("Versions")
            tc.formvalue('version_table', 'default', '2.0')
            tc.submit('apply')
            self._tester.go_to_admin("Ticket Types")
            tc.formvalue('enumtable', 'default', 'task')
            tc.submit('apply')

            self._tester.create_ticket('ticket summary')

            find_prop('component', 'component2')
            find_prop('milestone', 'milestone2')
            find_prop('priority', 'minor')
            find_prop('version', '2.0')
            find_prop('type', 'task')
        finally:
            self._testenv.remove_config('ticket', 'allowed_empty_fields')
Example #59
0
 def runTest(self):
     """Admin remove no selected version"""
     version_url = self._tester.url + "/admin/ticket/versions"
     tc.go(version_url)
     tc.submit('remove', formname='version_table')
     tc.find('No version selected')
Example #60
0
 def runTest(self):
     """Admin remove no selected component"""
     component_url = self._tester.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.submit('remove', formname='component_table')
     tc.find('No component selected')