Skip to content

Commit bffb97f

Browse files
author
Bob Ball
committed
Fix LVM unit tests.
The UT depend on a specific path for lvcreate binaries, however the path actually used is distro dependent. On Debian distros, lvcreate is in /sbin. SM correctly auto detects the location, but the UT were expecting it in /usr/sbin. Fix the UT so they use the detected path for the executables.
1 parent dd3e818 commit bffb97f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tests/lvmlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import optparse
2+
import lvutil
3+
import os
24

35

46
class LogicalVolume(object):
@@ -29,8 +31,8 @@ def __init__(self, logger, executable_injector):
2931
self.logger = logger
3032
self.lv_calls = []
3133
self._volume_groups = []
32-
executable_injector('/usr/sbin/lvcreate', self.fake_lvcreate)
33-
executable_injector('/usr/sbin/lvremove', self.fake_lvremove)
34+
executable_injector(os.path.join(lvutil.LVM_BIN, 'lvcreate'), self.fake_lvcreate)
35+
executable_injector(os.path.join(lvutil.LVM_BIN, 'lvremove'), self.fake_lvremove)
3436
executable_injector('/sbin/dmsetup', self.fake_dmsetup)
3537

3638
def add_volume_group(self, name):

tests/test_lvmlib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
import mock
3+
import os
34

45
import lvmlib
56

@@ -21,19 +22,21 @@ def test_lvcreate_is_mocked(self):
2122
executable_injector = mock.Mock()
2223

2324
lvsubsystem = lvmlib.LVSubsystem(None, executable_injector)
25+
lvcreate_path = os.path.join(lvmlib.lvutil.LVM_BIN, 'lvcreate')
2426

2527
self.assertTrue(
26-
mock.call('/usr/sbin/lvcreate', lvsubsystem.fake_lvcreate)
28+
mock.call(lvcreate_path, lvsubsystem.fake_lvcreate)
2729
in executable_injector.mock_calls
2830
)
2931

3032
def test_lvremove_is_mocked(self):
3133
executable_injector = mock.Mock()
3234

3335
lvsubsystem = lvmlib.LVSubsystem(None, executable_injector)
36+
lvremove_path = os.path.join(lvmlib.lvutil.LVM_BIN, 'lvremove')
3437

3538
self.assertTrue(
36-
mock.call('/usr/sbin/lvremove', lvsubsystem.fake_lvremove)
39+
mock.call(lvremove_path, lvsubsystem.fake_lvremove)
3740
in executable_injector.mock_calls
3841
)
3942

0 commit comments

Comments
 (0)