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
=== modified file 'charmhelpers/core/fstab.py'
--- charmhelpers/core/fstab.py 2014-06-02 16:35:43 +0000
+++ charmhelpers/core/fstab.py 2014-06-19 09:43:25 +0000
@@ -48,9 +48,11 @@
48 file.__init__(self, self._path, 'r+')48 file.__init__(self, self._path, 'r+')
4949
50 def _hydrate_entry(self, line):50 def _hydrate_entry(self, line):
51 # NOTE: use split with no arguments to split on any
52 # whitespace including tabs
51 return Fstab.Entry(*filter(53 return Fstab.Entry(*filter(
52 lambda x: x not in ('', None),54 lambda x: x not in ('', None),
53 line.strip("\n").split(" ")))55 line.strip("\n").split()))
5456
55 @property57 @property
56 def entries(self):58 def entries(self):
5759
=== modified file 'tests/core/test_fstab.py'
--- tests/core/test_fstab.py 2014-06-02 15:17:00 +0000
+++ tests/core/test_fstab.py 2014-06-19 09:43:25 +0000
@@ -13,10 +13,13 @@
1313
14DEFAULT_FSTAB_FILE = """/dev/sda /mnt/sda ext3 defaults 0 014DEFAULT_FSTAB_FILE = """/dev/sda /mnt/sda ext3 defaults 0 0
15/dev/sdb /mnt/sdb ext3 defaults 0 015/dev/sdb /mnt/sdb ext3 defaults 0 0
16/dev/sdc /mnt/sdc ext3 defaults 0 016/dev/sdc /mnt/sdc ext3 defaults 0 0
17UUID=3af44368-c50b-4768-8e58-aff003cef8be / ext4 errors=remount-ro 0 117UUID=3af44368-c50b-4768-8e58-aff003cef8be / ext4 errors=remount-ro 0 1
18"""18"""
1919
20# NOTE: helper will writeback with spaces instead of tabs
21GENERATED_FSTAB_FILE = DEFAULT_FSTAB_FILE.replace('\t', ' ')
22
2023
21class FstabTest(unittest.TestCase):24class FstabTest(unittest.TestCase):
2225
@@ -31,7 +34,7 @@
3134
32 def test_entries(self):35 def test_entries(self):
33 """Test if entries are correctly readed from fstab file"""36 """Test if entries are correctly readed from fstab file"""
34 assert_equal(sorted(DEFAULT_FSTAB_FILE.splitlines()),37 assert_equal(sorted(GENERATED_FSTAB_FILE.splitlines()),
35 sorted(str(entry) for entry in self.fstab.entries))38 sorted(str(entry) for entry in self.fstab.entries))
3639
37 def test_get_entry_by_device_attr(self):40 def test_get_entry_by_device_attr(self):
@@ -82,5 +85,5 @@
82 'UUID=3af44368-c50b-4768-8e58-aff003cef8be',85 'UUID=3af44368-c50b-4768-8e58-aff003cef8be',
83 '/', 'ext4', 'errors=remount-ro', 0, 1))86 '/', 'ext4', 'errors=remount-ro', 0, 1))
8487
85 assert_equal(sorted(DEFAULT_FSTAB_FILE.splitlines()),88 assert_equal(sorted(GENERATED_FSTAB_FILE.splitlines()),
86 sorted(str(entry) for entry in self.fstab.entries))89 sorted(str(entry) for entry in self.fstab.entries))
8790
=== modified file 'tests/tools/test_charm_helper_sync.py'
--- tests/tools/test_charm_helper_sync.py 2013-07-12 01:28:42 +0000
+++ tests/tools/test_charm_helper_sync.py 2014-06-19 09:43:25 +0000
@@ -22,7 +22,8 @@
22 '''It properly branches the correct helpers branch'''22 '''It properly branches the correct helpers branch'''
23 with patch('subprocess.check_call') as check_call:23 with patch('subprocess.check_call') as check_call:
24 sync.clone_helpers(work_dir='/tmp/foo', branch='lp:charm-helpers')24 sync.clone_helpers(work_dir='/tmp/foo', branch='lp:charm-helpers')
25 check_call.assert_called_with(['bzr', 'branch',25 check_call.assert_called_with(['bzr',
26 'checkout', '--lightweight',
26 'lp:charm-helpers',27 'lp:charm-helpers',
27 '/tmp/foo/charm-helpers'])28 '/tmp/foo/charm-helpers'])
2829

Subscribers

People subscribed via source and target branches