Пример #1
0
    def runTest(self):
        """Test for regression of https://trac.edgewall.org/ticket/11186
        TracError should be raised when repository with name already exists
        """
        def add_repository(name):
            tc.formvalue('trac-addrepos', 'name', name)
            tc.formvalue('trac-addrepos', 'dir', '/var/svn/%s' % name)
            tc.submit()

        def go_to_repository_admin():
            self._tester.go_to_admin()
            tc.follow("\\bRepositories\\b")
            tc.url(self._tester.url + '/admin/versioncontrol/repository')

        # TracError raised if repository already defined in database.
        go_to_repository_admin()
        name1 = random_word()
        add_repository(name1)
        tc.find('The repository "%s" has been added.' % name1)
        add_repository(name1)
        tc.find('The repository "%s" already exists.' % name1)
        tc.notfind(internal_error)

        # TracError raised if repository already defined in trac.ini.
        name2 = random_word().lower()
        env = self._testenv.get_trac_environment()
        env.config.set('repositories', '%s.dir' % name2, '/var/svn/%s' % name2)
        env.config.save()
        go_to_repository_admin()
        add_repository(name2)
        tc.find('The repository "%s" already exists.' % name2)
        tc.notfind(internal_error)
Пример #2
0
    def attach_file_to_ticket(self, ticketid, data=None, tempfilename=None,
                              description=None, replace=False,
                              content_type=None):
        """Attaches a file to the given ticket id, with random data if none is
        provided.  Assumes the ticket exists.
        """
        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if tempfilename is None:
            tempfilename = random_word()

        self.go_to_ticket(ticketid)
        # set the value to what it already is, so that twill will know we
        # want this form.
        tc.formvalue('attachfile', 'action', 'new')
        tc.submit()
        tc.url(self.url + "/attachment/ticket/" \
               "%s/\\?action=new&attachfilebutton=Attach\\+file" % ticketid)
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', tempfilename,
                    content_type=content_type, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid)
        return tempfilename
Пример #3
0
    def runTest(self):
        """Test for regression of http://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')

        word = random_word()
        names = ['%s_%d' % (word, n) for n in xrange(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])
        tc.formvalue('edit', 'name', names[2])
        tc.submit('save')
        tc.notfind(internal_error)
        tc.url(self._tester.url + '/admin/versioncontrol/repository')

        tc.follow('\\b' + names[2] + '\\b')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' +
               names[2])
        tc.formvalue('edit', 'name', names[0])
        tc.submit('save')
        tc.find('The repository "%s" already exists.' % names[0])
        tc.notfind(internal_error)
Пример #4
0
    def _attach_file_to_resource(self,
                                 realm,
                                 name,
                                 data=None,
                                 filename=None,
                                 description=None,
                                 replace=False,
                                 content_type=None):
        """Attaches a file to a resource. Assumes the resource exists and
           has already been navigated to."""

        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if filename is None:
            filename = random_word()

        tc.submit('attachfilebutton', 'attachfile')
        tc.url(self.url + r'/attachment/%s/%s/\?action=new$' % (realm, name))
        fp = io.BytesIO(data)
        tc.formfile('attachment',
                    'attachment',
                    filename,
                    content_type=content_type,
                    fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + r'/attachment/%s/%s/$' % (realm, name))

        return filename
Пример #5
0
    def runTest(self):
        """Test for regression of http://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")

        word = random_word()
        names = ["%s_%d" % (word, n) for n in xrange(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])
        tc.formvalue("edit", "name", names[2])
        tc.submit("save")
        tc.notfind(internal_error)
        tc.url(self._tester.url + "/admin/versioncontrol/repository")

        tc.follow("\\b" + names[2] + "\\b")
        tc.url(self._tester.url + "/admin/versioncontrol/repository/" + names[2])
        tc.formvalue("edit", "name", names[0])
        tc.submit("save")
        tc.find('The repository "%s" already exists.' % names[0])
        tc.notfind(internal_error)
Пример #6
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 "%s" 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 "%s" 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 "%s" already exists.' % name)
     tc.notfind(internal_error)
Пример #7
0
    def _attach_file_to_resource(self, realm, name, data=None,
                                 filename=None, description=None,
                                 replace=False, content_type=None):
        """Attaches a file to a resource. Assumes the resource exists and
           has already been navigated to."""

        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if filename is None:
            filename = random_word()

        tc.submit('attachfilebutton', 'attachfile')
        tc.url(self.url + '/attachment/%s/%s/\\?action=new&'
                          'attachfilebutton=Attach\\+file$' % (realm, name))
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', filename,
                    content_type=content_type, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/%s/%s/$' % (realm, name))

        return filename
Пример #8
0
    def runTest(self):
        """Test for regression of http://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')

        word = random_word()
        names = ['%s_%d' % (word, n) for n in xrange(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])
        tc.formvalue('trac-modrepos', 'name', names[2])
        tc.submit('save')
        tc.notfind(internal_error)
        tc.url(self._tester.url + '/admin/versioncontrol/repository')

        tc.follow('\\b' + names[2] + '\\b')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + names[2])
        tc.formvalue('trac-modrepos', 'name', names[0])
        tc.submit('save')
        tc.find('The repository "%s" already exists.' % names[0])
        tc.notfind(internal_error)
Пример #9
0
    def attach_file_to_ticket(self,
                              ticketid,
                              data=None,
                              tempfilename=None,
                              description=None,
                              replace=False):
        """Attaches a file to the given ticket id, with random data if none is
        provided.  Assumes the ticket exists.
        """
        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if tempfilename is None:
            tempfilename = random_word()

        self.go_to_ticket(ticketid)
        # set the value to what it already is, so that twill will know we
        # want this form.
        tc.formvalue('attachfile', 'action', 'new')
        tc.submit()
        tc.url(self.url + "/attachment/ticket/" \
               "%s/\\?action=new&attachfilebutton=Attach\\+file" % ticketid)
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid)
        return tempfilename
Пример #10
0
 def runTest(self):
     """Verify browser log for a new file"""
     tempfilename = random_word() + "_new.txt"
     fulltempfilename = "component1/trunk/" + tempfilename
     revision = self._testenv.svn_add(fulltempfilename, "")
     tc.go(self._tester.url + "/log/" + fulltempfilename)
     tc.find("@%d" % revision)
     tc.find("Add %s" % fulltempfilename)
Пример #11
0
 def runTest(self):
     """Verify browser log for a new file"""
     tempfilename = random_word() + '_new.txt'
     fulltempfilename = 'component1/trunk/' + tempfilename
     revision = self._testenv.svn_add(fulltempfilename, '')
     tc.go(self._tester.url + '/log/' + fulltempfilename)
     tc.find('@%d' % revision)
     tc.find('Add %s' % fulltempfilename)
Пример #12
0
 def runTest(self):
     """Verify browser log for a new file"""
     tempfilename = random_word() + '_new.txt'
     fulltempfilename = 'component1/trunk/' + tempfilename
     revision = self._testenv.svn_add(fulltempfilename, '')
     tc.go(self._tester.url + '/log/' + fulltempfilename)
     tc.find('@%d' % revision)
     tc.find('Add %s' % fulltempfilename)
Пример #13
0
    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
Пример #14
0
    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
Пример #15
0
 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)
Пример #16
0
 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)
Пример #17
0
    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
Пример #18
0
    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
Пример #19
0
 def attach_file_to_wiki(self, name, data=None):
     """Attaches a file to the given wiki page, with random content if none
     is provided.  Assumes the wiki page exists.
     """
     if data == None:
         data = random_page()
     self.go_to_wiki(name)
     # set the value to what it already is, so that twill will know we
     # want this form.
     tc.formvalue('attachfile', 'action', 'new')
     tc.submit()
     tc.url(self.url + "/attachment/wiki/" \
            "%s/\\?action=new&attachfilebutton=Attach\\+file" % name)
     tempfilename = random_word()
     fp = StringIO(data)
     tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
     tc.formvalue('attachment', 'description', random_sentence())
     tc.submit()
     tc.url(self.url + '/attachment/wiki/%s/$' % name)
Пример #20
0
 def attach_file_to_wiki(self, name, data=None):
     """Attaches a file to the given wiki page, with random content if none
     is provided.  Assumes the wiki page exists.
     """
     if data == None:
         data = random_page()
     self.go_to_wiki(name)
     # set the value to what it already is, so that twill will know we
     # want this form.
     tc.formvalue('attachfile', 'action', 'new')
     tc.submit()
     tc.url(self.url + "/attachment/wiki/" \
            "%s/\\?action=new&attachfilebutton=Attach\\+file" % name)
     tempfilename = random_word()
     fp = StringIO(data)
     tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
     tc.formvalue('attachment', 'description', random_sentence())
     tc.submit()
     tc.url(self.url + '/attachment/wiki/%s/$' % name)
     return tempfilename
Пример #21
0
    def runTest(self):
        """Add a file to the repository and verify it is in the browser"""
        # Add a file to Subversion
        tempfilename = random_word() + '_repo_browse.txt'
        fulltempfilename = 'component1/trunk/' + tempfilename
        revision = self._testenv.svn_add(fulltempfilename, random_page())

        # Verify that it appears in the browser view:
        browser_url = self._tester.url + '/browser'
        self._tester.go_to_url(browser_url)
        tc.find('component1')
        tc.follow('component1')
        tc.follow('trunk')
        tc.follow(tempfilename)
        self._tester.quickjump('[%s]' % revision)
        tc.find('Changeset %s' % revision)
        tc.find('admin')
        tc.find('Add %s' % fulltempfilename)
        tc.find('1 added')
        tc.follow('Timeline')
        tc.find('Add %s' % fulltempfilename)
Пример #22
0
    def runTest(self):
        """Add a file to the repository and verify it is in the browser"""
        # Add a file to Subversion
        tempfilename = random_word() + '_repo_browse.txt'
        fulltempfilename = 'component1/trunk/' + tempfilename
        revision = self._testenv.svn_add(fulltempfilename, random_page())

        # Verify that it appears in the browser view:
        browser_url = self._tester.url + '/browser'
        tc.go(browser_url)
        tc.url(browser_url)
        tc.find('component1')
        tc.follow('component1')
        tc.follow('trunk')
        tc.follow(tempfilename)
        self._tester.quickjump('[%s]' % revision)
        tc.find('Changeset %s' % revision)
        tc.find('admin')
        tc.find('Add %s' % fulltempfilename)
        tc.find('1 added')
        tc.follow('Timeline')
        tc.find('Add %s' % fulltempfilename)
Пример #23
0
    def runTest(self):
        """Add a file to the repository and verify it is in the browser"""
        # Add a file to Subversion
        tempfilename = random_word() + "_repo_browse.txt"
        fulltempfilename = "component1/trunk/" + tempfilename
        revision = self._testenv.svn_add(fulltempfilename, random_page())

        # Verify that it appears in the browser view:
        browser_url = self._tester.url + "/browser"
        tc.go(browser_url)
        tc.url(browser_url)
        tc.find("component1")
        tc.follow("component1")
        tc.follow("trunk")
        tc.follow(tempfilename)
        self._tester.quickjump("[%s]" % revision)
        tc.find("Changeset %s" % revision)
        tc.find("admin")
        tc.find("Add %s" % fulltempfilename)
        tc.find("1 added")
        tc.follow("Timeline")
        tc.find("Add %s" % fulltempfilename)
Пример #24
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()
     tc.find('The repository "%s" has been added.' % target)
     tc.formvalue('trac-addalias', 'name', name)
     tc.formvalue('trac-addalias', 'alias', target)
     tc.submit()
     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 "%s" already exists.' % name)
     tc.notfind(internal_error)
Пример #25
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)