# Path: tests/base.py
# LOG = oslo_logging.getLogger(__name__)
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=None, **kwargs):
#     def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
#         def raise_assertion(msg):
# 
# Path: virtman/compute_new.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class Compute(object):
# class Virtman(Compute):
#     def __init__(self):
#     def create(self, instance_name, image_name, image_connections, snapshot):
#     def destroy(self, instance_name):
#     def list(self):
#     def __init__(self, openstack_compatible=True):
#     def get_image_type(openstack_compatible):
#     def __del__(self):
#     def heartbeat_clock(self):
#     def heartbeat(self):
#     def _heartbeat(self):
#     def create(self, instance_name, image_name, image_connections,
#                snapshot=None):
#     def _create(self, instance_name, image_name, image_connections, snapshot):
#     def destroy(self, instance_name):
#     def _destroy(self, instance_name):
#     def list(self):
# 
# Path: virtman/drivers/fcg.py
# CONF = cfg.CONF
# class FcgExecutor(FCG):
#     def __init__(self):
# def is_valid():
# def create_group():
# def add_disk(disk):
# def rm_disk(disk):
# 
# Path: virtman/drivers/volt.py
# CONF = cfg.CONF
# def singleton(cls):
#     def _singleton(*args, **kwargs):
#     def __init__(self):
# def login(session_name, peer_id, host, port, iqn, lun):
# def logout(session_name, peer_id):
# def get(session_name, host):
# def heartbeat():
# class VoltClient(client.Client):
# 
# Path: virtman/image.py
# class FakeImage(Image):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#         super(FakeImage, self).__init__(image_name, image_connections,
#                                         base_image)
# 
#     def create_snapshot(self, instance_name, snapshot):
#         self.snapshots[instance_name] = instance_name
#         self.update_instance_status()
#         return '/dev/mapper/snapshot_' + instance_name
# 
#     def destroy_snapshot(self, instance_name):
#         del self.snapshots[instance_name]
#         self.update_instance_status()
#         return True
# 
#     def deploy_image(self):
#         if self.origin_path is None:
#             self.origin_path = '/dev/mapper/origin_' + self.image_name
# 
#     def destroy_image(self):
#         self.origin_path = None
#         return True
# 
#     def adjust_for_heartbeat(self, parents):
#         pass
# 
# Path: virtman/utils/exception.py
# LOG = logging.getLogger(__name__)
# class VirtmanException(Exception):
# class CreateBaseImageFailed(VirtmanException):
# class CreateSnapshotFailed(VirtmanException):
# class TestException(VirtmanException):
#     def __init__(self, message=None, **kwargs):
#     def __unicode__(self):


import mock
import logging
from tests import base
from virtman import compute_new
from virtman.drivers import fcg
from virtman.drivers import volt
from virtman.image import FakeImage
from virtman.utils import exception

    def test_create(self):
        expected_result1 = '0:/dev/mapper/snapshot_test_vm1'
        result1 = self.test_computer.create('test_vm1',
                                            'test_image',
                                            test_image_connections,
                                            test_snapshot_connection1)
        self.assertEqual(expected_result1, result1)

        expected_result2 = '0:/dev/mapper/snapshot_test_vm2'
        result2 = self.test_computer.create('test_vm2',
                                            'test_image',
                                            test_image_connections,
                                            test_snapshot_connection2)
        self.assertEqual(expected_result2, result2)

    def test_create_with_already_exist(self):
        self.test_computer.create('test_vm1',
                                  'test_image',
                                  test_image_connections,
                                  test_snapshot_connection1)
        expected_result = "1:Virtman: the instance_name 'test_vm1' " \
                          "already exists!"
        result = self.test_computer.create('test_vm1',
                                  'test_image',
                                  test_image_connections,
                                  test_snapshot_connection1)
        self.assertEqual(expected_result, result)

    def test_create_with_exception(self):

# Path: tests/base.py
# LOG = oslo_logging.getLogger(__name__)
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=None, **kwargs):
#     def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
#         def raise_assertion(msg):
# 
# Path: virtman/compute_new.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class Compute(object):
# class Virtman(Compute):
#     def __init__(self):
#     def create(self, instance_name, image_name, image_connections, snapshot):
#     def destroy(self, instance_name):
#     def list(self):
#     def __init__(self, openstack_compatible=True):
#     def get_image_type(openstack_compatible):
#     def __del__(self):
#     def heartbeat_clock(self):
#     def heartbeat(self):
#     def _heartbeat(self):
#     def create(self, instance_name, image_name, image_connections,
#                snapshot=None):
#     def _create(self, instance_name, image_name, image_connections, snapshot):
#     def destroy(self, instance_name):
#     def _destroy(self, instance_name):
#     def list(self):
# 
# Path: virtman/drivers/fcg.py
# CONF = cfg.CONF
# class FcgExecutor(FCG):
#     def __init__(self):
# def is_valid():
# def create_group():
# def add_disk(disk):
# def rm_disk(disk):
# 
# Path: virtman/drivers/volt.py
# CONF = cfg.CONF
# def singleton(cls):
#     def _singleton(*args, **kwargs):
#     def __init__(self):
# def login(session_name, peer_id, host, port, iqn, lun):
# def logout(session_name, peer_id):
# def get(session_name, host):
# def heartbeat():
# class VoltClient(client.Client):
# 
# Path: virtman/image.py
# class FakeImage(Image):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#         super(FakeImage, self).__init__(image_name, image_connections,
#                                         base_image)
# 
#     def create_snapshot(self, instance_name, snapshot):
#         self.snapshots[instance_name] = instance_name
#         self.update_instance_status()
#         return '/dev/mapper/snapshot_' + instance_name
# 
#     def destroy_snapshot(self, instance_name):
#         del self.snapshots[instance_name]
#         self.update_instance_status()
#         return True
# 
#     def deploy_image(self):
#         if self.origin_path is None:
#             self.origin_path = '/dev/mapper/origin_' + self.image_name
# 
#     def destroy_image(self):
#         self.origin_path = None
#         return True
# 
#     def adjust_for_heartbeat(self, parents):
#         pass
# 
# Path: virtman/utils/exception.py
# LOG = logging.getLogger(__name__)
# class VirtmanException(Exception):
# class CreateBaseImageFailed(VirtmanException):
# class CreateSnapshotFailed(VirtmanException):
# class TestException(VirtmanException):
#     def __init__(self, message=None, **kwargs):
#     def __unicode__(self):


# Path: tests/test_computer.py
import mock
import logging
from tests import base
from virtman import compute_new
from virtman.drivers import fcg
from virtman.drivers import volt
from virtman.image import FakeImage
from virtman.utils import exception


    def test_create(self):
        expected_result1 = '0:/dev/mapper/snapshot_test_vm1'
        result1 = self.test_computer.create('test_vm1',
                                            'test_image',
                                            test_image_connections,
                                            test_snapshot_connection1)
        self.assertEqual(expected_result1, result1)

        expected_result2 = '0:/dev/mapper/snapshot_test_vm2'
        result2 = self.test_computer.create('test_vm2',
                                            'test_image',
                                            test_image_connections,
                                            test_snapshot_connection2)
        self.assertEqual(expected_result2, result2)

    def test_create_with_already_exist(self):
        self.test_computer.create('test_vm1',
                                  'test_image',
                                  test_image_connections,
                                  test_snapshot_connection1)
        expected_result = "1:Virtman: the instance_name 'test_vm1' " \
                          "already exists!"
        result = self.test_computer.create('test_vm1',
                                  'test_image',
                                  test_image_connections,
                                  test_snapshot_connection1)
        self.assertEqual(expected_result, result)

    def test_create_with_exception(self):

        self.mock_object(FakeImage, 'deploy_image',