1. Olemis Lang
  2. bloodhound-mq

Commits

Olemis Lang  committed 191c0d2

BH Multiproduct #695 : Version control ops in test cases. Detect svn support at setUp time

... includes modifications to Trac's svn_add method to customize svn_add commit message and user name

  • Participants
  • Parent commits 1920642
  • Branches t695_commit_ticket_update

Comments (0)

Files changed (1)

File t695/t695_r1534486_commit_ticket_update.tests.func.diff

View file
 
 diff -r b34a5a7d744e bloodhound_multiproduct/tests/functional/versioncontrol.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/bloodhound_multiproduct/tests/functional/versioncontrol.py	Sun Dec 08 13:03:43 2013 -0500
-@@ -0,0 +1,179 @@
++++ b/bloodhound_multiproduct/tests/functional/versioncontrol.py	Sun Dec 08 16:04:27 2013 -0500
+@@ -0,0 +1,194 @@
 +# -*- coding: utf-8 -*-
 +#!/usr/bin/python
 +#
 +from trac.tests.functional import FunctionalTwillTestCaseSetup
 +from trac.tests.functional.tester import tc
 +
++from tests import unittest
++
 +class CommitTicketUpdaterTestCase(FunctionalTwillTestCaseSetup):
 +
 +    def _enable(self):
 +                                 product=GLOBAL_ENV)
 +
 +    def setUp(self):
++        if not has_svn:
++            errmsg = 'Unable to load svn support'
++            if hasattr(self, 'skipTest')
++                self.skipTest(errmsg)
++            else:
++                raise RuntimeError(errmsg)
 +        super(CommitTicketUpdaterTestCase, self).setUp()
 +        self._enable()
 +
 +        """
 +        with self.in_product(pid) as (testenv, tester):
 +            tester.go_to_ticket(tkt_id)
-+            # TODO: Assertions
-+        
++            tc.find('In <a [^>]*class="changeset" [^>]*>%s.*</a>' % 
++                    str(changeset.rev))
++            # TODO: More assertions ?
++
 +    # Map tickets to products (default=p1)
 +    TICKETS_MAP = {8 : 'p2', 9 : 'p2', 11: 'p3', 13: 'p2',
 +                   14: 'p3'}
 +                                 product=GLOBAL_ENV)
 +
 +        tempfilename = random_word()
-+        revision = self._testenv.svn_add(tempfilename, random_page())
++        revision = self._testenv.svn_add(tempfilename, random_page(),
++                                         msg=message)
 +
 +        for seqnum in xrange(1, self.MAX_TICKET_SEQNUM):
 +            pid = vars['t%s.product' % str(seqnum)]
 +        self._testenv._tracadmin('config', 'set', 'ticket',
 +                                 'commit_ticket_update_envelope', '{}',
 +                                 product=GLOBAL_ENV)
-+        # TODO: Commit files to create new changeset
++
++        tempfilename = random_word()
++        revision = self._testenv.svn_add(tempfilename, random_page(),
++                                         msg=message)
++
 +        for seqnum in xrange(1, self.MAX_TICKET_SEQNUM):
 +            pid = vars['t%s.product' % str(seqnum)]
 +            tid = vars['t' + str(seqnum)]
 +if __name__ == '__main__':
 +    unittest.main(defaultTest='test_suite')
 +
+diff -r b34a5a7d744e trac/trac/tests/functional/svntestenv.py
+--- a/trac/trac/tests/functional/svntestenv.py	Sun Dec 08 12:15:04 2013 -0500
++++ b/trac/trac/tests/functional/svntestenv.py	Sun Dec 08 16:04:27 2013 -0500
+@@ -52,7 +52,7 @@
+                 + [self.repo_url() + '/' + d for d in paths])
+         self.call_in_workdir(['svn', 'update'])
+ 
+-    def svn_add(self, filename, data):
++    def svn_add(self, filename, data, msg=None, username='admin'):
+         """Subversion helper to add a file to the given path within the main
+         repository.
+ 
+@@ -67,8 +67,10 @@
+         self.call_in_workdir(['svn', 'add', filename])
+         environ = os.environ.copy()
+         environ['LC_ALL'] = 'C'     # Force English messages in svn
+-        output = self.call_in_workdir(['svn', '--username=admin', 'commit', '-m',
+-                        'Add %s' % filename, filename], environ=environ)
++        if msg is None:
++            msg = 'Add %s' % filename
++        output = self.call_in_workdir(['svn', '--username=' + username, 
++                        'commit', '-m', msg, filename], environ=environ)
+         try:
+             revision = re.search(r'Committed revision ([0-9]+)\.',
+                                  output).group(1)