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 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 create_product(self, prefix=None, name=None, desc=None): """Create a product from the product list page.""" products_url = self.url + '/products' tc.go(products_url) tc.find('Products') tc.submit('add', 'new') tc.find('New Product') prefix = prefix or random_word() name = name or random_sentence() desc = desc or random_paragraph() tc.formvalue('edit', 'prefix', prefix) tc.formvalue('edit', 'name', name) tc.formvalue('edit', 'description', desc) tc.submit() tc.find('The product "%s" has been added' % prefix) return prefix, name
def admin_create_product(self, prefix=None, name=None, owner=None): """Create a product from the admin page.""" admin_product_url = self.url + '/admin/ticket/products' tc.go(admin_product_url) tc.url(admin_product_url + '$') prefix = prefix or random_word() name = name or random_sentence() owner = owner or random_word() tc.formvalue('addproduct', 'prefix', prefix) tc.formvalue('addproduct', 'name', name) tc.formvalue('addproduct', 'owner', owner) tc.submit() tc.find(r'The product "%s" has been added' % prefix) tc.find(r'<a href="/admin/ticket/products/%s">%s</a>' % (prefix, prefix)) tc.find(r'<a href="/admin/ticket/products/%s">%s</a>' % (prefix, name)) tc.find(r'<td class="owner">%s</td>' % owner) return prefix, name, owner
def start(self): """Starts the webserver, and waits for it to come up. Notice: Same as inherited method but without basic auth by default """ if 'FIGLEAF' in os.environ: exe = os.environ['FIGLEAF'] if ' ' in exe: # e.g. 'coverage run' args = exe.split() else: args = [exe] else: args = [sys.executable] options = self._tracd_options() if 'TRAC_TEST_TRACD_OPTIONS' in os.environ: options += os.environ['TRAC_TEST_TRACD_OPTIONS'].split() self.get_trac_environment().log.debug('Starting tracd with args ' + ' '.join(options)) args.append(os.path.join(self.trac_src, 'trac', 'web', 'standalone.py')) server = Popen( args + options + [self.tracdir], stdout=functional.logfile, stderr=functional.logfile, close_fds=close_fds, cwd=self.command_cwd, ) self.pid = server.pid # Verify that the url is ok timeout = 30 while timeout: try: tc.go(self.url) break except ConnectError: time.sleep(1) timeout -= 1 else: raise Exception('Timed out waiting for server to start.') tc.url(self.url)
def runTest(self): """Rename product from the admin page.""" prefix, name, owner = self._tester.admin_create_product(owner='admin') with self.in_product(prefix) as (testenv, tester): t1 = tester.create_ticket() t2 = tester.create_ticket() new_name = '%s%s' % (name, str(uuid.uuid4()).split('-')[0]) admin_product_url = self._tester.url + '/admin/ticket/products' tc.go(admin_product_url + '/' + prefix) tc.formvalue('modprod', 'name', new_name) tc.submit('save') tc.find("Your changes have been saved") tc.find(r'<a href="/admin/ticket/products/%s">%s</a>' % (prefix, new_name)) with self.in_product(prefix) as (testenv, tester): tester.go_to_ticket(t1) comment = "Product %s renamed to %s" % (name, new_name) tc.find(comment) tester.go_to_ticket(t2) tc.find(comment)
def start(self): """Starts the webserver, and waits for it to come up. Notice: Same as inherited method but without basic auth by default """ if 'FIGLEAF' in os.environ: exe = os.environ['FIGLEAF'] if ' ' in exe: # e.g. 'coverage run' args = exe.split() else: args = [exe] else: args = [sys.executable] options = self._tracd_options() if 'TRAC_TEST_TRACD_OPTIONS' in os.environ: options += os.environ['TRAC_TEST_TRACD_OPTIONS'].split() self.get_trac_environment().log.debug('Starting tracd with args ' + ' '.join(options)) args.append(os.path.join(self.trac_src, 'trac', 'web', 'standalone.py')) server = Popen(args + options + [self.tracdir], stdout=functional.logfile, stderr=functional.logfile, close_fds=close_fds, cwd=self.command_cwd, ) self.pid = server.pid # Verify that the url is ok timeout = 30 while timeout: try: tc.go(self.url) break except ConnectError: time.sleep(1) timeout -= 1 else: raise Exception('Timed out waiting for server to start.') tc.url(self.url)
def runTest(self): """Check for correct author in ticket comments on product rename https://issues.apache.org/bloodhound/ticket/671 """ prefix, name = self._tester.create_product() with self.in_product(prefix) as (testenv, tester): t1 = tester.create_ticket() t2 = tester.create_ticket() new_name = '%s%s' % (name, str(uuid4()).split('-')[0]) tc.go(self._tester.url + '/products') tc.follow('.*/products/' + prefix + r'\?action=edit$') tc.find('Edit Product') tc.find(prefix) tc.formvalue('edit', 'name', new_name) tc.submit() tc.find('Your changes have been saved') with self.in_product(prefix) as (testenv, tester): tester.go_to_ticket(t1) comment = 'Product %s renamed to %s' % (name, new_name) tc.find(comment) tester.go_to_ticket(t2) tc.find(comment)
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"')