def create_milestone(self, name=None, due=None): """Creates the specified milestone, with a random name if none is provided. Returns the name of the milestone. """ if name == None: name = random_unique_camel() milestone_url = self.url + "/admin/ticket/milestones" tc.go(milestone_url) tc.url(milestone_url) tc.formvalue('addmilestone', 'name', name) if due: # TODO: How should we deal with differences in date formats? tc.formvalue('addmilestone', 'duedate', due) tc.submit() tc.notfind(internal_error) tc.notfind('Milestone .* already exists') tc.url(milestone_url) tc.find(name) # Make sure it's on the roadmap. tc.follow('Roadmap') tc.url(self.url + "/roadmap") tc.find('Milestone:.*%s' % name) tc.follow(name) tc.url('%s/milestone/%s' % (self.url, unicode_quote(name))) if not due: # [BLOODHOUND] No date set => Unscheduled tc.find('Unscheduled') return name
def create_milestone(self, name=None, due=None): """Creates the specified milestone, with a random name if none is provided. Returns the name of the milestone. """ if name == None: name = random_unique_camel() milestone_url = self.url + "/admin/ticket/milestones" tc.go(milestone_url) tc.url(milestone_url) tc.formvalue('addmilestone', 'name', name) if due: # TODO: How should we deal with differences in date formats? tc.formvalue('addmilestone', 'duedate', due) tc.submit() tc.notfind(internal_error) tc.notfind('Milestone .* already exists') tc.url(milestone_url) tc.find(name) # Make sure it's on the roadmap. tc.follow('Roadmap') tc.url(self.url + "/roadmap") tc.find('Milestone:.*%s' % name) tc.follow(name) tc.url('%s/milestone/%s' % (self.url, unicode_quote(name))) if not due: # [BLOODHOUND] No date set => Unscheduled tc.find('Unscheduled') return name
def quick_create_ticket(self, summary=None, info=None): """Create a new (random) ticket in the test environment via quick create ticket shortcut. Returns the new ticket number. :param summary: may optionally be set to the desired summary :param info: may optionally be set to a dictionary of field value pairs for populating the ticket. Fields are populated afterwards by navigating to ticket page, thereby ``info['summary']``overrides ``summary``. `summary` and `description` default to randomly-generated values. """ self.go_to_front() tc.notfind(internal_error) if summary == None: summary = random_sentence(4) tc.formvalue('qct-form', 'field_summary', summary) tc.formvalue('qct-form', 'field_description', random_page()) self._post_create_ticket() if info: # Second pass to update ticket fields tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1)) tc.notfind(internal_error) for field, value in info.items(): tc.formvalue('inplace-propertyform', 'field_%s' % field, value) tc.submit('submit') return self.ticketcount
def quick_create_ticket(self, summary=None, info=None): """Create a new (random) ticket in the test environment via quick create ticket shortcut. Returns the new ticket number. :param summary: may optionally be set to the desired summary :param info: may optionally be set to a dictionary of field value pairs for populating the ticket. Fields are populated afterwards by navigating to ticket page, thereby ``info['summary']``overrides ``summary``. `summary` and `description` default to randomly-generated values. """ self.go_to_front() tc.notfind(internal_error) if summary == None: summary = random_sentence(4) tc.formvalue('qct-form', 'field_summary', summary) tc.formvalue('qct-form', 'field_description', random_page()) self._post_create_ticket() if info: # Second pass to update ticket fields tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1)) tc.notfind(internal_error) for field, value in info.items(): tc.formvalue('inplace-propertyform', 'field_%s' % field, value) tc.submit('submit') return self.ticketcount
def create_ticket(self, summary=None, info=None): """Create a new (random) ticket in the test environment. Returns the new ticket number. :param summary: may optionally be set to the desired summary :param info: may optionally be set to a dictionary of field value pairs for populating the ticket. ``info['summary']`` overrides summary. `summary` and `description` default to randomly-generated values. """ # [BLOODHOUND] New Ticket => More fields (in create ticket menu) self.go_to_newticket() tc.notfind(internal_error) if summary == None: summary = random_sentence(4) tc.formvalue('propertyform', 'field_summary', summary) tc.formvalue('propertyform', 'field_description', random_page()) if info: for field, value in info.items(): tc.formvalue('propertyform', 'field_%s' % field, value) # [BLOODHOUND] no actual button to submit /newticket `propertyform` tc.submit() self._post_create_ticket() return self.ticketcount
def create_ticket(self, summary=None, info=None): """Create a new (random) ticket in the test environment. Returns the new ticket number. :param summary: may optionally be set to the desired summary :param info: may optionally be set to a dictionary of field value pairs for populating the ticket. ``info['summary']`` overrides summary. `summary` and `description` default to randomly-generated values. """ # [BLOODHOUND] New Ticket => More fields (in create ticket menu) self.go_to_newticket() tc.notfind(internal_error) if summary == None: summary = random_sentence(4) tc.formvalue('propertyform', 'field_summary', summary) tc.formvalue('propertyform', 'field_description', random_page()) if info: for field, value in info.items(): tc.formvalue('propertyform', 'field_%s' % field, value) # [BLOODHOUND] no actual button to submit /newticket `propertyform` tc.submit() self._post_create_ticket() return self.ticketcount
def go_to_query(self): """Surf to the custom query page. """ self.go_to_front() # [BLOODHOUND] View Tickets (reports list) => Tickets (dashboard) tc.follow('^Tickets$') tc.notfind(internal_error) tc.url(self.url + '/dashboard') tc.follow('Custom Query') tc.url(self.url + '/query')
def go_to_query(self): """Surf to the custom query page. """ self.go_to_front() # [BLOODHOUND] View Tickets (reports list) => Tickets (dashboard) tc.follow('^Tickets$') tc.notfind(internal_error) tc.url(self.url + '/dashboard') tc.follow('Custom Query') tc.url(self.url + '/query')
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_front() # [BLOODHOUND] Preferences link removed tc.follow('/prefs') tc.follow('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): """Admin set default product""" prefix, name, owner = self._tester.admin_create_product(owner='admin') products_url = self._tester.url + '/admin/ticket/products' tc.go(products_url) tc.formvalue('product_table', 'default', prefix) tc.submit('apply') tc.find('type="radio" name="default" value="%s" checked="checked"' % prefix) tc.go(self._tester.url + '/newticket') tc.find('<option selected="selected" value="%s">%s</option>' % (prefix, name)) # Test the "Clear default" button tc.go(products_url) tc.submit('clear', 'product_table') tc.notfind('type="radio" name="default" value=".+" checked="checked"')
def runTest(self): """Admin set default product""" prefix, name, owner = self._tester.admin_create_product(owner='admin') products_url = self._tester.url + '/admin/ticket/products' tc.go(products_url) tc.formvalue('product_table', 'default', prefix) tc.submit('apply') tc.find('type="radio" name="default" value="%s" checked="checked"' % prefix) tc.go(self._tester.url + '/newticket') tc.find('<option selected="selected" value="%s">%s</option>' % (prefix, name)) # Test the "Clear default" button tc.go(products_url) tc.submit('clear', 'product_table') tc.notfind('type="radio" name="default" value=".+" checked="checked"')
def runTest(self): """User is redirected to the login page when the page they are navigating to is forbidden. """ env = self._testenv.get_trac_environment() actions = PermissionSystem(env).get_user_permissions('anonymous') # Revoke all permissions for 'anonymous' self._testenv._tracadmin('permission', 'remove', 'anonymous', *actions) self._testenv.restart() # TODO: can be removed when #539 is resolved try: with self._tester.as_user(None): tc.go(self._tester.url) tc.notfind(internal_error) tc.url(self._tester.url + '/login\?referer=%2F$') finally: self._testenv._tracadmin('permission', 'add', 'anonymous', *actions)
def runTest(self): """User is redirected to the login page when the page they are navigating to is forbidden. """ env = self._testenv.get_trac_environment() actions = PermissionSystem(env).get_user_permissions('anonymous') # Revoke all permissions for 'anonymous' self._testenv._tracadmin('permission', 'remove', 'anonymous', *actions) self._testenv.restart() # TODO: can be removed when #539 is resolved try: with self._tester.as_user(None): tc.go(self._tester.url) tc.notfind(internal_error) tc.url(self._tester.url + '/login\?referer=%2F$') finally: self._testenv._tracadmin('permission', 'add', 'anonymous', *actions)
def login(self, username): """Login as the given user Consider that 'logged in as user' label has been replaced by '<i class="icon-user"></i>user' """ #FIXME: Keep/remove this ? #tc.add_auth("", self.url, username, username) self.go_to_front() tc.find("Login") tc.follow("Login") # Submit user + password via account manager login form tc.formvalue('acctmgr_loginform', 'user', username) tc.formvalue('acctmgr_loginform', 'password', username) tc.submit() self.go_to_front() tc.find(r'<i class="icon-user"></i>\s*%s' % username) tc.find("Logout") tc.url(self.url) tc.notfind(internal_error)
def login(self, username): """Login as the given user Consider that 'logged in as user' label has been replaced by '<i class="icon-user"></i>user' """ #FIXME: Keep/remove this ? #tc.add_auth("", self.url, username, username) self.go_to_front() tc.find("Login") tc.follow("Login") # Submit user + password via account manager login form tc.formvalue('acctmgr_loginform', 'user', username) tc.formvalue('acctmgr_loginform', 'password', username) tc.submit() self.go_to_front() tc.find(r'<i class="icon-user"></i>\s*%s' % username) tc.find("Logout") tc.url(self.url) tc.notfind(internal_error)
def runTest(self): """Set preferences for admin user""" prefs_url = self._tester.url + "/prefs" # [BLOODHOUND] Preferences link removed tc.follow('/prefs') tc.url(prefs_url) 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.') tc.follow('Date & Time') tc.url(prefs_url + '/datetime') tc.formvalue('userprefs', 'tz', 'GMT -10:00') tc.submit() tc.find('Your preferences have been saved.') tc.follow('General') tc.url(prefs_url) tc.notfind('Your preferences have been saved.') tc.find('value="System Administrator"') tc.find(r'value="admin@example\.com"') tc.follow('Date & Time') tc.url(prefs_url + '/datetime') tc.find('GMT -10:00')
def create_report(self, title, query, description): """Create a new report with the given title, query, and description """ self.go_to_front() # [BLOODHOUND] View Tickets renamed to Tickets pointing at dashboard tc.follow(r'\bTickets\b') tc.notfind(internal_error) tc.follow(r'\bReports\b') tc.notfind(internal_error) tc.formvalue('create_report', 'action', 'new') # select new report form tc.submit() tc.find('New Report') tc.notfind(internal_error) tc.formvalue('edit_report', 'title', title) tc.formvalue('edit_report', 'description', description) tc.formvalue('edit_report', 'query', query) tc.submit() reportnum = b.get_url().split('/')[-1] # TODO: verify the url is correct # TODO: verify the report number is correct # TODO: verify the report does not cause an internal error # TODO: verify the title appears on the report list return reportnum
def create_report(self, title, query, description): """Create a new report with the given title, query, and description """ self.go_to_front() # [BLOODHOUND] View Tickets renamed to Tickets pointing at dashboard tc.follow(r'\bTickets\b') tc.notfind(internal_error) tc.follow(r'\bReports\b') tc.notfind(internal_error) tc.formvalue('create_report', 'action', 'new') # select new report form tc.submit() tc.find('New Report') tc.notfind(internal_error) tc.formvalue('edit_report', 'title', title) tc.formvalue('edit_report', 'description', description) tc.formvalue('edit_report', 'query', query) tc.submit() reportnum = b.get_url().split('/')[-1] # TODO: verify the url is correct # TODO: verify the report number is correct # TODO: verify the report does not cause an internal error # TODO: verify the title appears on the report list return reportnum
def quickjump(self, search): """Do a quick search to jump to a page.""" tc.formvalue('mainsearch', 'q', search) tc.submit() tc.notfind(internal_error)
def quickjump(self, search): """Do a quick search to jump to a page.""" tc.formvalue('mainsearch', 'q', search) tc.submit() tc.notfind(internal_error)