launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21372
[Merge] lp:~cjwatson/launchpad/snapcraft-fix-more-yaml-paths into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/snapcraft-fix-more-yaml-paths into lp:launchpad.
Commit message:
Fix loop exit condition when looking for snapcraft.yaml.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snapcraft-fix-more-yaml-paths/+merge/316328
Hooray for me for managing to write tests that proved that the code under test didn't work.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snapcraft-fix-more-yaml-paths into lp:launchpad.
=== modified file 'lib/lp/snappy/browser/snap.py'
--- lib/lp/snappy/browser/snap.py 2017-02-02 22:55:36 +0000
+++ lib/lp/snappy/browser/snap.py 2017-02-03 11:52:51 +0000
@@ -445,6 +445,7 @@
try:
blob = self.context.repository.getBlob(
path, self.context.name)
+ break
except GitRepositoryBlobNotFound:
if i == len(paths) - 1:
raise
=== modified file 'lib/lp/snappy/browser/tests/test_snap.py'
--- lib/lp/snappy/browser/tests/test_snap.py 2017-02-01 06:31:30 +0000
+++ lib/lp/snappy/browser/tests/test_snap.py 2017-02-03 11:52:51 +0000
@@ -485,9 +485,15 @@
self.assertContentEqual(
["386", "amd64"], [proc.name for proc in snap.processors])
- def test_initial_name_extraction_git(self):
+ def test_initial_name_extraction_git_snap_snapcraft_yaml(self):
+ def getBlob(filename, *args, **kwargs):
+ if filename == "snap/snapcraft.yaml":
+ return "name: test-snap"
+ else:
+ raise GitRepositoryBlobNotFound("dummy", filename)
+
[git_ref] = self.factory.makeGitRefs()
- git_ref.repository.getBlob = FakeMethod(result='name: test-snap')
+ git_ref.repository.getBlob = getBlob
view = create_initialized_view(git_ref, "+new-snap")
initial_values = view.initial_values
self.assertIn('store_name', initial_values)
@@ -498,28 +504,28 @@
if filename == "snapcraft.yaml":
return "name: test-snap"
else:
- raise GitRepositoryBlobNotFound()
+ raise GitRepositoryBlobNotFound("dummy", filename)
[git_ref] = self.factory.makeGitRefs()
git_ref.repository.getBlob = getBlob
view = create_initialized_view(git_ref, "+new-snap")
initial_values = view.initial_values
self.assertIn('store_name', initial_values)
- self.assertIsNone(initial_values['store_name'])
+ self.assertEqual('test-snap', initial_values['store_name'])
def test_initial_name_extraction_git_dot_snapcraft_yaml(self):
def getBlob(filename, *args, **kwargs):
if filename == ".snapcraft.yaml":
return "name: test-snap"
else:
- raise GitRepositoryBlobNotFound()
+ raise GitRepositoryBlobNotFound("dummy", filename)
[git_ref] = self.factory.makeGitRefs()
git_ref.repository.getBlob = getBlob
view = create_initialized_view(git_ref, "+new-snap")
initial_values = view.initial_values
self.assertIn('store_name', initial_values)
- self.assertIsNone(initial_values['store_name'])
+ self.assertEqual('test-snap', initial_values['store_name'])
def test_initial_name_extraction_git_repo_error(self):
[git_ref] = self.factory.makeGitRefs()
Follow ups