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)
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")
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')
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')
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">')
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()
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.')
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')
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)
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)
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"))
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)
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))
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')
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'))
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))
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')
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>')
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)
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>')
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)
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"')
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)
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')
def runTest(self): """Admin remove priority""" name = "RemovePriority" self._tester.create_priority(name) priority_url = self._tester.url + '/admin/ticket/priority' tc.go(priority_url) tc.url(priority_url + '$') tc.find(name) tc.formvalue('enumtable', 'sel', name) tc.submit('remove') tc.url(priority_url + '$') tc.notfind(name)
def runTest(self): """Admin milestone completed""" name = "CompletedMilestone" self._tester.create_milestone(name) milestone_url = self._tester.url + "/admin/ticket/milestones" tc.go(milestone_url) tc.url(milestone_url) tc.follow(name) tc.url(milestone_url + '/' + name) tc.formvalue('edit', 'completed', True) tc.submit('save') tc.url(milestone_url + "$")
def runTest(self): """Admin modify priority""" name = "ModifyPriority" self._tester.create_priority(name) priority_url = self._tester.url + '/admin/ticket/priority' tc.go(priority_url) tc.url(priority_url + '$') tc.find(name) tc.follow(name) tc.formvalue('edit', 'name', name * 2) tc.submit('save') tc.url(priority_url + '$') tc.find(name * 2)
def runTest(self): # First login, anonymous may not be allowed to do anything self._tester.login_as(Usernames.admin) bug_id = self._tester.create_new_agilo_ticket('bug', 'Nothing happens') task_id = self._tester.create_referenced_ticket(bug_id, Type.TASK, 'Think about fixing it') self._tester.go_to_view_ticket_page(bug_id) tc.find('value="delete link"') tc.formvalue('delete_link', 'cmd', 'delete') # select the correct form tc.submit('cmd') tc.code(200) self.assertTrue(self._tester.browser_shows_ticket_edit_page(bug_id)) self._assert_task_is_not_linked_to_bug(task_id, bug_id)
def runTest(self): # It is important that the new ticket form works even if another default # ticket type was set. self._tester.login_as(Usernames.admin) self._tester.set_default_ticket_type(Type.TASK) self._tester.login_as(Usernames.product_owner) self._tester.go_to_new_ticket_page('requirement') tc.formvalue('propertyform', 'field-summary', 'blah') # This implicitly checks that the additional fields for # requirements are visible tc.formvalue('propertyform', 'field-businessvalue', '+200') tc.submit('preview')
def runTest(self): """Set default handler.""" # Project default_handler is selected. self._tester.go_to_preferences("User Interface") tc.notfind(r'<option[^>]+selected="selected"') tc.find("Default: WikiModule") try: # Project default handler still selected after value is changed. hint = "SearchModule is not a valid IRequestHandler or is not" \ " enabled\." self._testenv.set_config('trac', 'default_handler', 'SearchModule') self._tester.go_to_preferences("User Interface") tc.notfind('<option[^>]+selected="selected"') tc.find("Default: SearchModule") tc.notfind(hint) # Project default handler still selected after module is disabled. component = 'trac.search.web_ui.*' self._testenv.set_config('components', component, 'disabled') self._tester.go_to_preferences("User Interface") try: tc.notfind('<option[^>]+selected="selected"') tc.find(r"Default: SearchModule") tc.find(hint) finally: self._testenv.remove_config('components', component) finally: self._testenv.set_config('trac', 'default_handler', 'WikiModule') # Set session default handler and navigate to base URL. tc.formvalue('userprefs', 'default_handler', 'TimelineModule') tc.submit() tc.find("Your preferences have been saved\.") tc.find('<option[^>]+selected="selected"[^>]+TimelineModule') self._tester.go_to_front() tc.find("<h1>Timeline</h1>") # Clear session default handler. self._tester.go_to_preferences("User Interface") tc.formvalue('userprefs', 'default_handler', '') tc.submit() tc.find("Your preferences have been saved\.") tc.notfind(r'<option[^>]+selected="selected"') tc.find("Default: WikiModule")
def runTest(self): """Admin remove multiple versions""" name = "MultiRemoveVersion" count = 3 for i in xrange(count): self._tester.create_version("%s%s" % (name, i)) version_url = self._tester.url + '/admin/ticket/versions' tc.go(version_url) tc.url(version_url + '$') for i in xrange(count): tc.find("%s%s" % (name, i)) for i in xrange(count): tc.formvalue('version_table', 'sel', "%s%s" % (name, i)) tc.submit('remove') tc.url(version_url + '$') for i in xrange(count): tc.notfind("%s%s" % (name, i))
def runTest(self): """Admin remove multiple priorities""" name = "MultiRemovePriority" count = 3 for i in xrange(count): self._tester.create_priority("%s%s" % (name, i)) priority_url = self._tester.url + '/admin/ticket/priority' tc.go(priority_url) tc.url(priority_url + '$') for i in xrange(count): tc.find("%s%s" % (name, i)) for i in xrange(count): tc.formvalue('enumtable', 'sel', "%s%s" % (name, i)) tc.submit('remove') tc.url(priority_url + '$') for i in xrange(count): tc.notfind("%s%s" % (name, i))
def runTest(self): """Admin remove multiple milestones""" name = "MultiRemoveMilestone" count = 3 for i in xrange(count): self._tester.create_milestone("%s%s" % (name, i)) milestone_url = self._tester.url + '/admin/ticket/milestones' tc.go(milestone_url) tc.url(milestone_url + '$') for i in xrange(count): tc.find("%s%s" % (name, i)) for i in xrange(count): tc.formvalue('milestone_table', 'sel', "%s%s" % (name, i)) tc.submit('remove') tc.url(milestone_url + '$') for i in xrange(count): tc.notfind("%s%s" % (name, i))
def runTest(self): """Admin milestone completed in the future""" name = "CompletedFutureMilestone" self._tester.create_milestone(name) milestone_url = self._tester.url + "/admin/ticket/milestones" tc.go(milestone_url) tc.url(milestone_url) tc.follow(name) tc.url(milestone_url + '/' + name) tc.formvalue('edit', 'completed', True) cdate = datetime_now(tz=utc) + timedelta(days=2) cdate_string = format_date(cdate, tzinfo=localtz, locale=locale_en) tc.formvalue('edit', 'completeddate', cdate_string) tc.submit('save') tc.find('Completion date may not be in the future') # And make sure it wasn't marked as completed. self._tester.go_to_roadmap() tc.find(name)
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.formvalue('modifypage', 'action', 'edit') tc.submit() 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.formvalue('modifypage', 'action', 'edit') tc.submit() 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._tracadmin('trac', 'permission_policies', ', '.join(pp_list)) self._testenv.grant_perm('user', 'WIKI_ADMIN') self._tester.go_to_wiki(page_name) tc.formvalue('modifypage', 'action', 'edit') tc.submit() 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')
def runTest(self): """Admin modify milestone duedate on detail page""" name = "DetailDueMilestone" # Create a milestone self._tester.create_milestone(name) # Modify the details of the milestone milestone_url = self._tester.url + "/admin/ticket/milestones" tc.go(milestone_url) tc.url(milestone_url) tc.follow(name) tc.url(milestone_url + '/' + name) duedate = datetime_now(tz=utc) duedate_string = format_datetime(duedate, tzinfo=utc, locale=locale_en) tc.formvalue('edit', 'due', True) tc.formvalue('edit', 'duedate', duedate_string) tc.submit('save') tc.url(milestone_url + '$') tc.find(name + '(<[^>]*>|\\s)*' + duedate_string, 's')
def runTest(self): '''Checks that a modified description produces a description diff and we can look at that diff later as well as the ticket history page.''' self._tester.login_as(Usernames.admin) ticket_id = self._tester.create_new_agilo_task( 'Blub', 'The boring description') self._tester.go_to_view_ticket_page(ticket_id) tc.formvalue('propertyform', 'field_description', 'A new, exciting description') tc.submit('submit') self._tester.go_to_view_ticket_page(ticket_id) tc.follow('diff') tc.code(200) # There seems to be no easyer way to get to the ticket history page tc.follow('Ticket History') tc.code(200)
def runTest(self): """Admin set default version""" name = self._tester.create_version() 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. self._tester.go_to_url('/newticket') tc.find('<option selected="selected" value="%s">%s</option>' % (name, name)) # Test the "Clear default" button self._tester.go_to_url('/admin/ticket/versions') 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">)')
def runTest(self): """Test for regression of http://trac.edgewall.org/ticket/11319 Only alphanumeric characters can be used for session key in advanced panel. """ try: self._tester.logout() self._tester.go_to_preferences('Advanced') tc.formvalue('userprefs', 'newsid', 'ลeลลion_id') tc.submit('change') tc.notfind(internal_error) tc.find('Session ID must be alphanumeric') self._tester.go_to_preferences('Advanced') tc.formvalue('userprefs', 'loadsid', 'ลeลลion_id') tc.submit('restore') tc.notfind(internal_error) tc.find('Session ID must be alphanumeric') finally: self._tester.login('admin')
def runTest(self): pagename = self._tester.create_wiki_page() self._tester.edit_wiki_page(pagename) tc.follow(r"\bHistory\b") tc.url(self._tester.url + r'/wiki/%s\?action=history' % pagename) version_link = '<td class="version">[ \t\n]*' \ '<a href="/wiki/%(pagename)s\?version=%%(version)s" ' \ 'title="View this version">%%(version)s[ \t\n]*</a>' \ % {'pagename': pagename} tc.find(version_link % {'version': 1}) tc.find(version_link % {'version': 2}) 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' % (self._tester.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})
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.path, 'plugins', plugin_name + '.py'), """\ from genshi.builder import tag from trac.core import Component, implements from trac.util.translation import tag_ from trac.wiki.api import IWikiPageManipulator class WikiPageManipulator(Component): implements(IWikiPageManipulator) def prepare_wiki_page(self, req, page, fields): pass def validate_wiki_page(self, req, page): field = 'comment' yield None, tag_("The page contains invalid markup at" " line %(number)s.", number=tag.strong('10')) yield field, tag_("The field %(field)s cannot be empty.", field=tag.strong(field)) """) self._testenv.restart() try: self._tester.go_to_front() tc.follow("Wiki") tc.formvalue('modifypage', 'action', 'edit') tc.submit() tc.submit('save', 'edit') tc.url(self._tester.url + '/wiki/WikiStart$') 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()
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: name = self._testenv.add_component(comp.name, comp.owner)
def runTest(self): # Setting the a default type different from the ticket type to be # created triggered another bug in the preview display... self._tester.login_as(Usernames.admin) self._tester.login_as(Usernames.product_owner) title = 'Foo Bar Title' ticket_id = self._tester.create_new_agilo_userstory(title) self._tester.go_to_view_ticket_page(ticket_id) new_title = 'bulb' tc.formvalue('propertyform', 'summary', new_title) tc.submit('preview') tc.code(200) from agilo.ticket.api import AgiloTicketSystem if AgiloTicketSystem.is_trac_1_0(): tc.find('<span[^>]*>%s</span>' % new_title) else: tc.find('<h2[^>]*>%s</h2>' % new_title)
def runTest(self): """Admin remove milestone""" name = self._testenv.add_milestone() tid = self._tester.create_ticket(info={'milestone': name}) milestone_url = self._tester.url + '/admin/ticket/milestones' self._tester.go_to_url(milestone_url) tc.formvalue('milestone_table', 'sel', name) tc.submit('remove') tc.url(milestone_url, regexp=False) tc.notfind(name) self._tester.go_to_ticket(tid) tc.find('<th class="missing" id="h_milestone">' '[ \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")
def runTest(self): """Admin set default component""" name = self._testenv.add_component() self._tester.go_to_url('/admin/ticket/components') tc.formvalue('component_table', 'default', name) tc.submit('apply') tc.find('type="radio" name="default" checked="checked" value="%s"' % name) self._tester.go_to_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') self._tester.go_to_url('/admin/ticket/components') tc.submit('clear', formname='component_table') tc.notfind('type="radio" name="default" checked="checked" value=".+"') self._tester.create_ticket() tc.find(r'<th class="missing" id="h_component">\s*Component:\s*</th>' r'\s*<td headers="h_component">\s*</td>') self._testenv.remove_config('ticket', 'allowed_empty_fields')
def runTest(self): """Test for regression of http://trac.edgewall.org/ticket/11584 don't raise NoSuchChangeset for empty repository if no "rev" parameter """ repo_path = self._testenv.svnadmin_create('repo-t11584') self._tester.go_to_admin() tc.follow("\\bRepositories\\b") tc.url(self._tester.url + '/admin/versioncontrol/repository') tc.formvalue('trac-addrepos', 'name', 't11584') tc.formvalue('trac-addrepos', 'dir', repo_path) tc.submit() tc.notfind(internal_error) self._testenv._tracadmin('repository', 'sync', 't11584') browser_url = self._tester.url + '/browser/t11584' tc.go(browser_url) tc.url(browser_url) tc.notfind('Error: No such changeset')
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>\\)')
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)
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('%s/wiki/%s?action=history' % (url, pagename), regexp=False) 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(formname='history') 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})
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')
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)
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.')
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)
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')
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')
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')
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.formvalue('modifypage', 'action', 'edit') tc.submit() tc.submit('save', 'edit') tc.url(self._tester.url + '/wiki/WikiStart$') 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()
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)
def runTest(self): """Test for regression of http://trac.edgewall.org/ticket/11186 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') name = random_word() tc.formvalue('trac-addrepos', 'name', name) tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % name) tc.submit() tc.find('The repository "%s" has been added.' % name) tc.formvalue('trac-addrepos', 'name', name) tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % name) tc.submit() tc.find('The repository "%s" already exists.' % name) tc.notfind(internal_error)