Merge lp:~james-page/charm-helpers/fstab-tabs into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 163
Proposed branch: lp:~james-page/charm-helpers/fstab-tabs
Merge into: lp:charm-helpers
Diff against target: 64 lines (+11/-5)
3 files modified
charmhelpers/core/fstab.py (+3/-1)
tests/core/test_fstab.py (+6/-3)
tests/tools/test_charm_helper_sync.py (+2/-1)
To merge this branch: bzr merge lp:~james-page/charm-helpers/fstab-tabs
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+223699@code.launchpad.net

Description of the change

Fixup problem with fstab parsing if tabs are used instead of spaces

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/fstab.py'
2--- charmhelpers/core/fstab.py 2014-06-02 16:35:43 +0000
3+++ charmhelpers/core/fstab.py 2014-06-19 09:43:25 +0000
4@@ -48,9 +48,11 @@
5 file.__init__(self, self._path, 'r+')
6
7 def _hydrate_entry(self, line):
8+ # NOTE: use split with no arguments to split on any
9+ # whitespace including tabs
10 return Fstab.Entry(*filter(
11 lambda x: x not in ('', None),
12- line.strip("\n").split(" ")))
13+ line.strip("\n").split()))
14
15 @property
16 def entries(self):
17
18=== modified file 'tests/core/test_fstab.py'
19--- tests/core/test_fstab.py 2014-06-02 15:17:00 +0000
20+++ tests/core/test_fstab.py 2014-06-19 09:43:25 +0000
21@@ -13,10 +13,13 @@
22
23 DEFAULT_FSTAB_FILE = """/dev/sda /mnt/sda ext3 defaults 0 0
24 /dev/sdb /mnt/sdb ext3 defaults 0 0
25-/dev/sdc /mnt/sdc ext3 defaults 0 0
26+/dev/sdc /mnt/sdc ext3 defaults 0 0
27 UUID=3af44368-c50b-4768-8e58-aff003cef8be / ext4 errors=remount-ro 0 1
28 """
29
30+# NOTE: helper will writeback with spaces instead of tabs
31+GENERATED_FSTAB_FILE = DEFAULT_FSTAB_FILE.replace('\t', ' ')
32+
33
34 class FstabTest(unittest.TestCase):
35
36@@ -31,7 +34,7 @@
37
38 def test_entries(self):
39 """Test if entries are correctly readed from fstab file"""
40- assert_equal(sorted(DEFAULT_FSTAB_FILE.splitlines()),
41+ assert_equal(sorted(GENERATED_FSTAB_FILE.splitlines()),
42 sorted(str(entry) for entry in self.fstab.entries))
43
44 def test_get_entry_by_device_attr(self):
45@@ -82,5 +85,5 @@
46 'UUID=3af44368-c50b-4768-8e58-aff003cef8be',
47 '/', 'ext4', 'errors=remount-ro', 0, 1))
48
49- assert_equal(sorted(DEFAULT_FSTAB_FILE.splitlines()),
50+ assert_equal(sorted(GENERATED_FSTAB_FILE.splitlines()),
51 sorted(str(entry) for entry in self.fstab.entries))
52
53=== modified file 'tests/tools/test_charm_helper_sync.py'
54--- tests/tools/test_charm_helper_sync.py 2013-07-12 01:28:42 +0000
55+++ tests/tools/test_charm_helper_sync.py 2014-06-19 09:43:25 +0000
56@@ -22,7 +22,8 @@
57 '''It properly branches the correct helpers branch'''
58 with patch('subprocess.check_call') as check_call:
59 sync.clone_helpers(work_dir='/tmp/foo', branch='lp:charm-helpers')
60- check_call.assert_called_with(['bzr', 'branch',
61+ check_call.assert_called_with(['bzr',
62+ 'checkout', '--lightweight',
63 'lp:charm-helpers',
64 '/tmp/foo/charm-helpers'])
65

Subscribers

People subscribed via source and target branches