def test__mount(self, mkdtemp, umount): ''' Test mounting a device in a temporary place. ''' mkdtemp.return_value = '/tmp/xxx' states_mock = { 'mount.mounted': MagicMock(return_value={'result': True}), } with patch.dict(btrfs.__states__, states_mock): assert btrfs._mount('/dev/sda1') == '/tmp/xxx' mkdtemp.assert_called_once() states_mock['mount.mounted'].assert_called_with('/tmp/xxx', device='/dev/sda1', fstype='btrfs', opts='subvol=/', persist=False) umount.assert_not_called()
def test__mount_use_default(self, mkdtemp, umount): """ Test mounting a device in a temporary place. """ mkdtemp.return_value = "/tmp/xxx" states_mock = { "mount.mounted": MagicMock(return_value={"result": True}), } with patch.dict(btrfs.__states__, states_mock): assert btrfs._mount("/dev/sda1", use_default=True) == "/tmp/xxx" mkdtemp.assert_called_once() states_mock["mount.mounted"].assert_called_with( "/tmp/xxx", device="/dev/sda1", fstype="btrfs", opts="defaults", persist=False, ) umount.assert_not_called()