def create_component(self, name=None, owner=None, description=None): """Creates the specified component, with a random camel-cased name if none is provided. Returns the name.""" if name is None: name = random_unique_camel() component_url = self.url + "/admin/ticket/components" tc.go(component_url) tc.url(component_url) tc.formvalue('addcomponent', 'name', name) if owner is not None: tc.formvalue('addcomponent', 'owner', owner) tc.submit() # Verify the component appears in the component list tc.url(component_url) tc.find(name) tc.notfind(internal_error) if description is not None: tc.follow(r"\b%s\b" % name) tc.formvalue('modcomp', 'description', description) tc.submit('save') tc.url(component_url) tc.find("Your changes have been saved.") tc.notfind(internal_error) # TODO: verify the component shows up in the newticket page return name
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. """ self.go_to_front() tc.follow(r"\bNew Ticket\b") tc.notfind(internal_error) if summary is None: summary = random_sentence(5) 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) tc.submit('submit') # we should be looking at the newly created ticket tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1)) tc.notfind(internal_error) # Increment self.ticketcount /after/ we've verified that the ticket # was created so a failure does not trigger spurious later # failures. self.ticketcount += 1 return self.ticketcount
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 is 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(r"\bRoadmap\b") tc.url(self.url + "/roadmap") tc.find('Milestone:.*%s' % name) tc.follow(r"\b%s\b" % name) tc.url('%s/milestone/%s' % (self.url, unicode_quote(name))) if not due: tc.find('No date set') return name
def create_component(self, name=None, owner=None, description=None): """Creates the specified component, with a random camel-cased name if none is provided. Returns the name.""" if name is None: name = random_unique_camel() component_url = self.url + "/admin/ticket/components" tc.go(component_url) tc.url(component_url) tc.formvalue('addcomponent', 'name', name) if owner is not None: tc.formvalue('addcomponent', 'owner', owner) tc.submit() # Verify the component appears in the component list tc.url(component_url) tc.find(name) tc.notfind(internal_error) if description is not None: tc.follow(r"\b%s\b" % name) tc.formvalue('edit', 'description', description) tc.submit('save') tc.url(component_url) tc.find("Your changes have been saved.") tc.notfind(internal_error) # TODO: verify the component shows up in the newticket page 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: tc.find('No date set') return name
def login(self, username): """Login as the given user""" tc.add_auth("", self.url, username, username) self.go_to_front() tc.find("Login") tc.follow("Login") # We've provided authentication info earlier, so this should # redirect back to the base url. tc.find("logged in as %s" % username) tc.find("Logout") tc.url(self.url) tc.notfind(internal_error)
def login(self, username): """Login as the given user""" username = to_utf8(username) tc.add_auth("", self.url, username, username) self.go_to_front() tc.find("Login") tc.follow(r"\bLogin\b") # We've provided authentication info earlier, so this should # redirect back to the base url. tc.find('logged in as[ \t\n]+<span class="trac-author-user">%s</span>' % username) tc.find("Logout") tc.url(self.url) tc.notfind(internal_error)
def create_version(self, name=None, releasetime=None): """Create a new version. The name defaults to a random camel-cased word if not provided.""" version_admin = self.url + "/admin/ticket/versions" if name == None: name = random_unique_camel() tc.go(version_admin) tc.url(version_admin) tc.formvalue('addversion', 'name', name) if releasetime != None: tc.formvalue('addversion', 'time', releasetime) tc.submit() tc.url(version_admin) tc.find(name) tc.notfind(internal_error)
def create_version(self, name=None, releasetime=None): """Create a new version. The name defaults to a random camel-cased word if not provided.""" version_admin = self.url + "/admin/ticket/versions" if name is None: name = random_unique_camel() tc.go(version_admin) tc.url(version_admin) tc.formvalue('addversion', 'name', name) if releasetime is not None: tc.formvalue('addversion', 'time', releasetime) tc.submit() tc.url(version_admin) tc.find(name) tc.notfind(internal_error)
def create_enum(self, kind, name=None): """Helper to create the specified enum (used for ``priority``, ``severity``, etc). If no name is given, a unique random word is used. The name is returned. """ if name is None: name = random_unique_camel() enum_url = self.url + "/admin/ticket/" + kind self.go_to_url(enum_url) tc.formvalue('addenum', 'name', name) tc.submit() tc.url(re.escape(enum_url) + '#?$') tc.find(name) tc.notfind(internal_error) return name
def create_enum(self, kind, name=None): """Helper to create the specified enum (used for ``priority``, ``severity``, etc). If no name is given, a unique random word is used. The name is returned. """ if name == None: name = random_unique_camel() priority_url = self.url + "/admin/ticket/" + kind tc.go(priority_url) tc.url(priority_url) tc.formvalue('addenum', 'name', name) tc.submit() tc.url(priority_url) tc.find(name) tc.notfind(internal_error) return name
def create_report(self, title, query, description): """Create a new report with the given title, query, and description""" self.go_to_front() tc.follow(r"\bView Tickets\b") tc.submit(formname='create_report') 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_component(self, name=None, user=None): """Creates the specified component, with a random camel-cased name if none is provided. Returns the name.""" if name == None: name = random_unique_camel() component_url = self.url + "/admin/ticket/components" tc.go(component_url) tc.url(component_url) tc.formvalue('addcomponent', 'name', name) if user != None: tc.formvalue('addcomponent', 'owner', user) tc.submit() # Verify the component appears in the component list tc.url(component_url) tc.find(name) tc.notfind(internal_error) # TODO: verify the component shows up in the newticket page return name
def create_report(self, title, query, description): """Create a new report with the given title, query, and description""" self.go_to_front() tc.follow('View Tickets') tc.formvalue('create_report', 'action', 'new') # select the right 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 login(self, username): """Login as the given user""" tc.add_auth('', self.url + '/login', username, username) self.go_to_front() tc.find("Login") url = self.url.replace('://', '://{0}:{0}@'.format(unicode_quote(username))) url = '%s/login?referer=%s' % (url, unicode_quote(self.url)) tc.go(url) tc.notfind(internal_error) tc.url(self.url, regexp=False) # We've provided authentication info earlier, so this should # redirect back to the base url. tc.find( 'logged in as[ \t\n]+<span class="trac-author-user">%s</span>' % username) tc.find("Logout") tc.url(self.url, regexp=False) tc.notfind(internal_error)
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 is None: name = random_unique_camel() milestone_url = self.url + "/admin/ticket/milestones" self.go_to_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, regexp=False) tc.find(name) return name
def quickjump(self, search): """Do a quick search to jump to a page.""" tc.formvalue('search', 'q', search) tc.submit() tc.notfind(internal_error)
def logout(self): """Logout""" tc.submit('logout', 'logout') tc.notfind(internal_error) tc.notfind('logged in as')
def go_to_url(self, url): tc.go(url) tc.url(re.escape(url)) tc.notfind(internal_error)
def go_to_front(self): """Go to the Trac front page""" tc.go(self.url) tc.url(self.url) tc.notfind(internal_error)
def go_to_url(self, url): tc.go(url) tc.url(url) tc.notfind(internal_error)
def logout(self): """Logout""" tc.follow("Logout") tc.notfind(internal_error)
def go_to_url(self, url): if url.startswith('/'): url = self.url + url tc.go(url) tc.url(url, regexp=False) tc.notfind(internal_error)