[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/codeimport-source-details-refactor into lp:launchpad

2016-10-12 Thread noreply
The proposal to merge lp:~cjwatson/launchpad/codeimport-source-details-refactor 
into lp:launchpad has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/codeimport-source-details-refactor/+merge/308117
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/codeimport-source-details-refactor into lp:launchpad

2016-10-12 Thread William Grant
Review: Approve code


-- 
https://code.launchpad.net/~cjwatson/launchpad/codeimport-source-details-refactor/+merge/308117
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/codeimport-source-details-refactor into lp:launchpad

2016-10-11 Thread Colin Watson
Colin Watson has proposed merging 
lp:~cjwatson/launchpad/codeimport-source-details-refactor into lp:launchpad 
with lp:~cjwatson/launchpad/codeimport-git-auth as a prerequisite.

Commit message:
Refactor CodeImportSourceDetails.fromCodeImport to 
CodeImportSourceDetails.fromCodeImportJob, to make it easier to issue macaroons 
in future.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1469459 in Launchpad itself: "import external code into a LP git repo 
(natively)"
  https://bugs.launchpad.net/launchpad/+bug/1469459

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/codeimport-source-details-refactor/+merge/308117
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/codeimport-source-details-refactor into lp:launchpad.
=== modified file 'lib/lp/code/xmlrpc/codeimportscheduler.py'
--- lib/lp/code/xmlrpc/codeimportscheduler.py	2015-07-08 16:05:11 +
+++ lib/lp/code/xmlrpc/codeimportscheduler.py	2016-10-11 13:11:47 +
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """The code import scheduler XML-RPC API."""
@@ -67,8 +67,8 @@
 @return_fault
 def _getImportDataForJobID(self, job_id):
 job = self._getJob(job_id)
-arguments = CodeImportSourceDetails.fromCodeImport(
-job.code_import).asArguments()
+arguments = CodeImportSourceDetails.fromCodeImportJob(
+job).asArguments()
 branch = job.code_import.branch
 branch_url = canonical_url(branch)
 log_file_name = '%s.log' % branch.unique_name[1:].replace('/', '-')

=== modified file 'lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py'
--- lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py	2011-12-30 06:14:56 +
+++ lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py	2016-10-11 13:11:47 +
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test for the methods of `ICodeImportScheduler`."""
@@ -63,8 +63,8 @@
 code_import = removeSecurityProxy(code_import_job).code_import
 code_import_arguments, branch_url, log_file_name = \
 self.api.getImportDataForJobID(code_import_job.id)
-import_as_arguments = CodeImportSourceDetails.fromCodeImport(
-code_import).asArguments()
+import_as_arguments = CodeImportSourceDetails.fromCodeImportJob(
+code_import_job).asArguments()
 expected_log_file_name = '%s.log' % (
 code_import.branch.unique_name[1:].replace('/', '-'))
 self.assertEqual(

=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py	2016-10-05 14:08:09 +
+++ lib/lp/codehosting/codeimport/tests/test_worker.py	2016-10-11 13:11:47 +
@@ -48,6 +48,7 @@
 import subvertpy
 import subvertpy.client
 import subvertpy.ra
+from testtools.matchers import Equals
 
 from lp.app.enums import InformationType
 from lp.code.interfaces.codehosting import (
@@ -1394,70 +1395,64 @@
 # Use an admin user as we aren't checking edit permissions here.
 TestCaseWithFactory.setUp(self, 'ad...@canonical.com')
 
+def assertArgumentsMatch(self, code_import, matcher):
+job = self.factory.makeCodeImportJob(code_import=code_import)
+details = CodeImportSourceDetails.fromCodeImportJob(job)
+self.assertThat(details.asArguments(), matcher)
+
 def test_bzr_arguments(self):
 code_import = self.factory.makeCodeImport(
 bzr_branch_url="http://example.com/foo;)
-arguments = CodeImportSourceDetails.fromCodeImport(
-code_import).asArguments()
-self.assertEquals([
-str(code_import.branch.id), 'bzr', 'http://example.com/foo'],
-arguments)
+self.assertArgumentsMatch(
+code_import, Equals([
+str(code_import.branch.id), 'bzr',
+'http://example.com/foo']))
 
 def test_git_arguments(self):
 code_import = self.factory.makeCodeImport(
-git_repo_url="git://git.example.com/project.git")
-arguments = CodeImportSourceDetails.fromCodeImport(
-code_import).asArguments()
-self.assertEquals([
-str(code_import.branch.id), 'git',
-'git://git.example.com/project.git'],
-arguments)
+git_repo_url="git://git.example.com/project.git")
+self.assertArgumentsMatch(
+code_import, Equals([
+str(code_import.branch.id), 'git',
+'git://git.example.com/project.git']))
 
 def