示例#1
0
    def test_do_diff_mission_correctly_except_omit_the_final_whitespace(self):
        self.client.post(reverse(views.resetrepo))
        response = self.client.get(reverse('svn_checkout'))
        checkoutdir = tempfile.mkdtemp()
        try:
            # Check the repository out and make the required change.
            subprocess.check_call(['svn', 'checkout', response.context['checkout_url'], checkoutdir])
            new_contents = open(os.path.join(controllers.get_mission_data_path('svn'), controllers.SvnDiffMission.NEW_CONTENT)).read()
            open(os.path.join(checkoutdir, controllers.SvnDiffMission.FILE_TO_BE_PATCHED), 'w').write(new_contents)

            # Make the diff.
            diff = subproc_check_output(['svn', 'diff'], cwd=checkoutdir)

            # Many users fail to copy-paste the diff properly. In particular,
            # they omit trailing whitespace characters. Let's remove the last line.
            self.assertEqual(' \n', diff[-2:])
            diff = diff[:-2]

            # Submit the diff.
            response = self.client.post(reverse(views.diff_submit), {'diff': diff})
            paulproteus = Person.objects.get(user__username='******')
            self.assert_(controllers.mission_completed(paulproteus, 'svn_diff'))

            # Check that there is a new commit that applies to the working copy cleanly.
            update_output = subproc_check_output(['svn', 'update'], cwd=checkoutdir)
            self.assert_('Updated to revision ' in update_output)
        finally:
            shutil.rmtree(checkoutdir)
示例#2
0
def mock_get_file_good(repo, txn, filename):
    if filename == 'trunk/'+controllers.SvnCommitMission.SECRET_WORD_FILE:
        return controllers.SvnCommitMission.NEW_SECRET_WORD+'\n'
    elif filename == 'trunk/'+controllers.SvnCommitMission.FILE_TO_BE_PATCHED:
        return open(controllers.SvnCommitMission.NEW_CONTENT).read()
    else:
        subproc_check_output(['false'])
示例#3
0
    def test_do_diff_mission_correctly(self):
        self.client.post(reverse(views.resetrepo))
        response = self.client.get(reverse('svn_checkout'))
        checkoutdir = tempfile.mkdtemp()
        try:
            # Check the repository out and make the required change.
            subprocess.check_call(
                ['svn', 'checkout', response.context['checkout_url'],
                 checkoutdir])
            new_contents = open(
                os.path.join(view_helpers.get_mission_data_path('svn'),
                             DiffForm.NEW_CONTENT)).read()
            open(os.path.join(checkoutdir, DiffForm.FILE_TO_BE_PATCHED),
                 'w').write(new_contents)

            # Make the diff.
            diff = subproc_check_output(['svn', 'diff'], cwd=checkoutdir)

            # Submit the diff.
            response = self.client.post(
                reverse(views.diff_submit), {'diff': diff})
            paulproteus = Person.objects.get(user__username='******')
            self.assert_(
                view_helpers.mission_completed(paulproteus, 'svn_diff'))

            # Check that there is a new commit that applies to the working
            # copy cleanly.
            update_output = subproc_check_output(
                ['svn', 'update'], cwd=checkoutdir)
            self.assert_('Updated to revision ' in update_output)
        finally:
            shutil.rmtree(checkoutdir)
示例#4
0
    def test_do_diff_mission_correctly(self):
        self.client.post(reverse(views.resetrepo))
        response = self.client.get(reverse('svn_checkout'))
        checkoutdir = tempfile.mkdtemp()
        try:
            # Check the repository out and make the required change.
            subprocess.check_call([
                'svn', 'checkout', response.context['checkout_url'],
                checkoutdir
            ])
            new_contents = open(
                os.path.join(view_helpers.get_mission_data_path('svn'),
                             DiffForm.NEW_CONTENT)).read()
            open(os.path.join(checkoutdir, DiffForm.FILE_TO_BE_PATCHED),
                 'w').write(new_contents)

            # Make the diff.
            diff = subproc_check_output(['svn', 'diff'], cwd=checkoutdir)

            # Submit the diff.
            response = self.client.post(reverse(views.diff_submit),
                                        {'diff': diff})
            paulproteus = Person.objects.get(user__username='******')
            self.assert_(
                view_helpers.mission_completed(paulproteus, 'svn_diff'))

            # Check that there is a new commit that applies to the working
            # copy cleanly.
            update_output = subproc_check_output(['svn', 'update'],
                                                 cwd=checkoutdir)
            self.assert_('Updated to revision ' in update_output)
        finally:
            shutil.rmtree(checkoutdir)
示例#5
0
def mock_get_file_good(repo, txn, filename):
    if filename == 'trunk/' + view_helpers.SvnCommitMission.SECRET_WORD_FILE:
        return view_helpers.SvnCommitMission.NEW_SECRET_WORD + '\n'
    elif filename == 'trunk/' + view_helpers.SvnCommitMission.FILE_TO_BE_PATCHED:
        return open(view_helpers.SvnCommitMission.NEW_CONTENT).read()
    else:
        subproc_check_output(['false'])
示例#6
0
 def get_info(self, path):
     svninfo = subproc_check_output(['svn', 'info', 'file://'+path])
     info = {}
     for line in svninfo.splitlines():
         if ': ' in line:
             key, separator, value = line.partition(': ')
             info[key] = value
     return info
示例#7
0
 def get_info(self, path):
     svninfo = subproc_check_output(['svn', 'info', 'file://' + path])
     info = {}
     for line in svninfo.splitlines():
         if ': ' in line:
             key, separator, value = line.partition(': ')
             info[key] = value
     return info
示例#8
0
 def get_info(self, path):
     svninfo = subproc_check_output(["svn", "info", "file://" + path])
     info = {}
     for line in svninfo.splitlines():
         if ": " in line:
             key, separator, value = line.partition(": ")
             info[key] = value
     return info
示例#9
0
    def test_do_diff_mission_correctly_except_omit_the_final_whitespace(self):
        self.client.post(reverse(views.resetrepo))
        response = self.client.get(reverse(views.checkout))
        checkoutdir = tempfile.mkdtemp()
        try:
            # Check the repository out and make the required change.
            subprocess.check_call([
                'svn', 'checkout', response.context['checkout_url'],
                checkoutdir
            ])
            new_contents = open(
                os.path.join(controllers.get_mission_data_path('svn'),
                             controllers.SvnDiffMission.NEW_CONTENT)).read()
            open(
                os.path.join(checkoutdir,
                             controllers.SvnDiffMission.FILE_TO_BE_PATCHED),
                'w').write(new_contents)

            # Make the diff.
            diff = subproc_check_output(['svn', 'diff'], cwd=checkoutdir)

            # Many users fail to copy-paste the diff properly. In particular,
            # they omit trailing whitespace characters. Let's remove the last line.
            self.assertEqual(' \n', diff[-2:])
            diff = diff[:-2]

            # Submit the diff.
            response = self.client.post(reverse(views.diff_submit),
                                        {'diff': diff})
            paulproteus = Person.objects.get(user__username='******')
            self.assert_(controllers.mission_completed(paulproteus,
                                                       'svn_diff'))

            # Check that there is a new commit that applies to the working copy cleanly.
            update_output = subproc_check_output(['svn', 'update'],
                                                 cwd=checkoutdir)
            self.assert_('Updated to revision ' in update_output)
        finally:
            shutil.rmtree(checkoutdir)
示例#10
0
    def test_do_diff_mission_correctly(self):
        self.client.post(reverse(views.resetrepo))
        response = self.client.get(reverse("svn_checkout"))
        checkoutdir = tempfile.mkdtemp()
        try:
            # Check the repository out and make the required change.
            subprocess.check_call(["svn", "checkout", response.context["checkout_url"], checkoutdir])
            new_contents = open(os.path.join(controllers.get_mission_data_path("svn"), DiffForm.NEW_CONTENT)).read()
            open(os.path.join(checkoutdir, DiffForm.FILE_TO_BE_PATCHED), "w").write(new_contents)

            # Make the diff.
            diff = subproc_check_output(["svn", "diff"], cwd=checkoutdir)

            # Submit the diff.
            response = self.client.post(reverse(views.diff_submit), {"diff": diff})
            paulproteus = Person.objects.get(user__username="******")
            self.assert_(controllers.mission_completed(paulproteus, "svn_diff"))

            # Check that there is a new commit that applies to the working copy cleanly.
            update_output = subproc_check_output(["svn", "update"], cwd=checkoutdir)
            self.assert_("Updated to revision " in update_output)
        finally:
            shutil.rmtree(checkoutdir)