# Path: ssmlib/main.py
# def main(args=None):
# 
#     if args:
#         sys.argv = args.split()
# 
#     options = Options()
#     PR.set_options(options)
#     storage = StorageHandle(options)
#     ssm_parser = SsmParser(storage)
#     args = ssm_parser.parse()
# 
#     # Check create command dependency
#     if args.func == storage.create:
#         if not args.raid:
#             if (args.stripesize):
#                 err = "You can not specify --stripesize without specifying" + \
#                       " RAID level!"
#                 ssm_parser.parser_create.error(err)
#             if (args.stripes):
#                 err = "You can not specify --stripes without specifying" + \
#                       " RAID level!"
#                 ssm_parser.parser_create.error(err)
#         # This should be changed to be future proofed and every time we add
#         # new options to any of the commands it would need to be enabled
#         # in each backend if appropriate
#         if args.virtual_size and args.pool.type not in ["lvm", "thin"]:
#                 err = "Backed '{0}' does not".format(args.pool.type) + \
#                       " support --virtual-size option!"
#                 ssm_parser.parser_create.error(err)
# 
#     options.verbose = args.verbose
#     options.force = args.force
# 
#     if args.vv or args.vvv:
#         options.verbose = True
#         options.vv = True
# 
#     if args.vvv:
#         options.vvv = True
# 
# 
#     #storage.set_globals(args.force, args.verbose, args.yes, args.config)
#     storage.set_globals(options)
# 
#     # Register clean-up function on exit
#     atexit.register(misc.do_cleanup)
# 
#     if args.dry_run:
#         return 0
# 
#     try:
#         args.func(args)
#     except argparse.ArgumentTypeError as ex:
#         ssm_parser.parser.error(ex)
# 
#     return 0
# 
# Path: ssmlib/misc.py
#     def __next__(iter):
#     def __next__(iter):
#     def __str__(x):
#     def __str__(x):
# def get_unit_size(string):
# def is_number(string):
# def get_real_size(size):
# def get_perc_size_argument(string):
# def get_slaves(devname):
# def send_udev_event(device, event):
# def udev_settle():
# def get_device_by_uuid(uuid):
# def get_major_minor(device):
# def get_file_size(path):
# def check_binary(name):
# def do_mount(device, directory, options=None):
# def do_umount(mpoint, all_targets=False):
# def temp_mount(device, options=None):
# def temp_umount(mpoint=None):
# def do_cleanup():
# def get_signature(device, types=None):
# def get_fs_type(device):
# def get_real_device(device):
# def get_swaps():
# def get_partitions():
# def get_mountinfo(regex=".*"):
# def get_mounts_old(regex=".*"):
# def get_mounts(regex=".*"):
# def get_dmnumber(name):
# def udev_checkpoint(devices):
# def wipefs(devices, signatures):
# def humanize_size(arg):
# def run(cmd, show_cmd=False, stdout=False, stderr=True, can_fail=False,
#         stdin_data=None, return_stdout=True):
# def chain(*iterables):
#     def izip(*iterables):
#     def izip(*iterables):
# def compress(data, selectors):
# def permutations(iterable, r=None):
# def terminal_size(default=(25, 80)):
#     def _ioctl_GWINSZ(fd):
# def is_bdevice(path):
# def get_device_size(device):
# def ptable(data, table_header=None):
#     def __init__(self):
#     def neighbours(self):
#     def parents(self):
#     def children(self):
#     def add_neighbour(self, node):
#     def add_children(self, node):
#     def add_parent(self, node):
#     def get_roots(self):
#     def find_node(name, node_cls):
# TMP_MOUNTED = []
# VERBOSE_VV_FLAG = False
# VERBOSE_VVV_FLAG = False
# class Node(object):


import sys
import unittest
import argparse
from ssmlib import main
from ssmlib import misc
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Common classes for unit testing



class MyStdout(object):
    def __init__(self):
        self.output = ""
        self.stdout = sys.stdout

    def write(self, s):
        self.output += s


class BaseStorageHandleInit(unittest.TestCase):
    """
    Initialize StorageHandle class and some mock functions.
    """

    def setUp(self):
        self.storage = main.StorageHandle()
        self.run_data = []

# Path: ssmlib/main.py
# def main(args=None):
# 
#     if args:
#         sys.argv = args.split()
# 
#     options = Options()
#     PR.set_options(options)
#     storage = StorageHandle(options)
#     ssm_parser = SsmParser(storage)
#     args = ssm_parser.parse()
# 
#     # Check create command dependency
#     if args.func == storage.create:
#         if not args.raid:
#             if (args.stripesize):
#                 err = "You can not specify --stripesize without specifying" + \
#                       " RAID level!"
#                 ssm_parser.parser_create.error(err)
#             if (args.stripes):
#                 err = "You can not specify --stripes without specifying" + \
#                       " RAID level!"
#                 ssm_parser.parser_create.error(err)
#         # This should be changed to be future proofed and every time we add
#         # new options to any of the commands it would need to be enabled
#         # in each backend if appropriate
#         if args.virtual_size and args.pool.type not in ["lvm", "thin"]:
#                 err = "Backed '{0}' does not".format(args.pool.type) + \
#                       " support --virtual-size option!"
#                 ssm_parser.parser_create.error(err)
# 
#     options.verbose = args.verbose
#     options.force = args.force
# 
#     if args.vv or args.vvv:
#         options.verbose = True
#         options.vv = True
# 
#     if args.vvv:
#         options.vvv = True
# 
# 
#     #storage.set_globals(args.force, args.verbose, args.yes, args.config)
#     storage.set_globals(options)
# 
#     # Register clean-up function on exit
#     atexit.register(misc.do_cleanup)
# 
#     if args.dry_run:
#         return 0
# 
#     try:
#         args.func(args)
#     except argparse.ArgumentTypeError as ex:
#         ssm_parser.parser.error(ex)
# 
#     return 0
# 
# Path: ssmlib/misc.py
#     def __next__(iter):
#     def __next__(iter):
#     def __str__(x):
#     def __str__(x):
# def get_unit_size(string):
# def is_number(string):
# def get_real_size(size):
# def get_perc_size_argument(string):
# def get_slaves(devname):
# def send_udev_event(device, event):
# def udev_settle():
# def get_device_by_uuid(uuid):
# def get_major_minor(device):
# def get_file_size(path):
# def check_binary(name):
# def do_mount(device, directory, options=None):
# def do_umount(mpoint, all_targets=False):
# def temp_mount(device, options=None):
# def temp_umount(mpoint=None):
# def do_cleanup():
# def get_signature(device, types=None):
# def get_fs_type(device):
# def get_real_device(device):
# def get_swaps():
# def get_partitions():
# def get_mountinfo(regex=".*"):
# def get_mounts_old(regex=".*"):
# def get_mounts(regex=".*"):
# def get_dmnumber(name):
# def udev_checkpoint(devices):
# def wipefs(devices, signatures):
# def humanize_size(arg):
# def run(cmd, show_cmd=False, stdout=False, stderr=True, can_fail=False,
#         stdin_data=None, return_stdout=True):
# def chain(*iterables):
#     def izip(*iterables):
#     def izip(*iterables):
# def compress(data, selectors):
# def permutations(iterable, r=None):
# def terminal_size(default=(25, 80)):
#     def _ioctl_GWINSZ(fd):
# def is_bdevice(path):
# def get_device_size(device):
# def ptable(data, table_header=None):
#     def __init__(self):
#     def neighbours(self):
#     def parents(self):
#     def children(self):
#     def add_neighbour(self, node):
#     def add_children(self, node):
#     def add_parent(self, node):
#     def get_roots(self):
#     def find_node(name, node_cls):
# TMP_MOUNTED = []
# VERBOSE_VV_FLAG = False
# VERBOSE_VVV_FLAG = False
# class Node(object):


# Path: tests/unittests/common.py
import sys
import unittest
import argparse
from ssmlib import main
from ssmlib import misc

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Common classes for unit testing



class MyStdout(object):
    def __init__(self):
        self.output = ""
        self.stdout = sys.stdout

    def write(self, s):
        self.output += s


class BaseStorageHandleInit(unittest.TestCase):
    """
    Initialize StorageHandle class and some mock functions.
    """

    def setUp(self):
        self.storage = main.StorageHandle()
        self.run_data = []

        self.run_orig = misc.run