Merge lp:~marcoceppi/charm-helpers/lp-1591968 into lp:charm-helpers

Proposed by Marco Ceppi
Status: Merged
Merged at revision: 585
Proposed branch: lp:~marcoceppi/charm-helpers/lp-1591968
Merge into: lp:charm-helpers
Diff against target: 51 lines (+20/-7)
2 files modified
charmhelpers/fetch/bzrurl.py (+3/-2)
tests/fetch/test_bzrurl.py (+17/-5)
To merge this branch: bzr merge lp:~marcoceppi/charm-helpers/lp-1591968
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+297186@code.launchpad.net

Description of the change

Do not create dest_dir, but instead create dest (dirname of dest_dir).

To post a comment you must log in.
583. By Marco Ceppi <marco@T430>

test coverage

Revision history for this message
Stuart Bishop (stub) wrote :

Looks good. Unrelated tests are failing (bug reported), but that shouldn't block this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/fetch/bzrurl.py'
2--- charmhelpers/fetch/bzrurl.py 2015-12-10 21:01:00 +0000
3+++ charmhelpers/fetch/bzrurl.py 2016-06-13 13:53:01 +0000
4@@ -59,8 +59,9 @@
5 dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
6 branch_name)
7
8- if not os.path.exists(dest_dir):
9- mkdir(dest_dir, perms=0o755)
10+ if dest and not os.path.exists(dest):
11+ mkdir(dest, perms=0o755)
12+
13 try:
14 self.branch(source, dest_dir)
15 except OSError as e:
16
17=== modified file 'tests/fetch/test_bzrurl.py'
18--- tests/fetch/test_bzrurl.py 2015-12-10 20:53:41 +0000
19+++ tests/fetch/test_bzrurl.py 2016-06-13 13:53:01 +0000
20@@ -94,14 +94,26 @@
21 if dst:
22 shutil.rmtree(dst, ignore_errors=True)
23
24+ def test_installs(self):
25+ self.fh.branch = MagicMock()
26+
27+ for url in self.valid_urls:
28+ branch_name = urlparse(url).path.strip("/").split("/")[-1]
29+ dest = os.path.join('foo', 'fetched')
30+ dest_dir = os.path.join(dest, os.path.basename(branch_name))
31+ with patch.dict('os.environ', {'CHARM_DIR': 'foo'}):
32+ where = self.fh.install(url)
33+ self.assertEqual(where, dest_dir)
34+
35 @patch('charmhelpers.fetch.bzrurl.mkdir')
36- def test_installs(self, _mkdir):
37+ def test_installs_dir(self, _mkdir):
38 self.fh.branch = MagicMock()
39
40 for url in self.valid_urls:
41 branch_name = urlparse(url).path.strip("/").split("/")[-1]
42- dest = os.path.join('foo', 'fetched', os.path.basename(branch_name))
43+ dest = os.path.join('opt', 'f')
44+ dest_dir = os.path.join(dest, os.path.basename(branch_name))
45 with patch.dict('os.environ', {'CHARM_DIR': 'foo'}):
46- where = self.fh.install(url)
47- self.assertEqual(where, dest)
48- _mkdir.assert_called_with(where, perms=0o755)
49+ where = self.fh.install(url, dest)
50+ self.assertEqual(where, dest_dir)
51+ _mkdir.assert_called_with(dest, perms=0o755)

Subscribers

People subscribed via source and target branches