Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LVM unit tests. #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/lvmlib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import optparse
import lvutil
import os


class LogicalVolume(object):
Expand Down Expand Up @@ -29,8 +31,8 @@ def __init__(self, logger, executable_injector):
self.logger = logger
self.lv_calls = []
self._volume_groups = []
executable_injector('/usr/sbin/lvcreate', self.fake_lvcreate)
executable_injector('/usr/sbin/lvremove', self.fake_lvremove)
executable_injector(os.path.join(lvutil.LVM_BIN, 'lvcreate'), self.fake_lvcreate)
executable_injector(os.path.join(lvutil.LVM_BIN, 'lvremove'), self.fake_lvremove)
executable_injector('/sbin/dmsetup', self.fake_dmsetup)

def add_volume_group(self, name):
Expand Down
7 changes: 5 additions & 2 deletions tests/test_lvmlib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import mock
import os

import lvmlib

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

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

self.assertTrue(
mock.call('/usr/sbin/lvcreate', lvsubsystem.fake_lvcreate)
mock.call(lvcreate_path, lvsubsystem.fake_lvcreate)
in executable_injector.mock_calls
)

def test_lvremove_is_mocked(self):
executable_injector = mock.Mock()

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

self.assertTrue(
mock.call('/usr/sbin/lvremove', lvsubsystem.fake_lvremove)
mock.call(lvremove_path, lvsubsystem.fake_lvremove)
in executable_injector.mock_calls
)

Expand Down