# Path: core/exceptions.py
# class CreationException(Exception):
#     pass
# 
# Path: tests/helpers.py
# class BaseTestCase(unittest.TestCase):
#     def shortDescription(self):
#         return None
# 
# def custom_wait(self):
#     self.ready = True
#     self.checking = False
#     yield self.ready
# 
# def wait_for(condition, timeout=10):
#     start = time.time()
#     while not condition() and time.time() - start < timeout:
#         time.sleep(0.1)
# 
#     return condition()
# 
# class DatabaseMock(Mock):
#     active_sessions = {}
#     endpoints = {}
# 
#     def __init__(self, *args, **kwargs):
#         super(DatabaseMock, self).__init__(*args, **kwargs)
#         self.add = Mock(side_effect=set_primary_key)
# 
#     def get_active_sessions(self, provider_id=None):
#         return self.active_sessions.values()
# 
#     def get_session(self, session_id):
#         return self.active_sessions.get(str(session_id))
# 
#     def get_endpoint(self, endpoint):
#         pass
# 
#     def get_endpoints(self, *args, **kwargs):
#         return self.endpoints.values()
# 
#     @staticmethod
#     def get_last_session_step(session_id):
#         return Mock()
# 
#     def register_provider(self, name, url, platforms):
#         from core.db.models import Provider
#         return Provider(name, url, platforms)
# 
# Path: core/db/models.py
# class Provider(Base, FeaturesMixin):
#     __tablename__ = 'providers'
# 
#     id = Column(Integer, primary_key=True)
#     name = Column(String(length=200), nullable=True)
#     url = Column(String, nullable=True)
#     active = Column(Boolean, default=False)
#     config = Column(JSON, default={})
#     max_limit = Column(Integer, default=0)
# 
#     def __init__(self, name, url, config=None, active=True, max_limit=0):
#         self.name = name
#         self.url = url
#         self.active = active
#         self.max_limit = max_limit
# 
#         if config:
#             self.config = config
# 
#     @property
#     def info(self):
#         return {
#             "id": self.id,
#             "name": self.name,
#             "url": self.url
#         }


import os
from core.exceptions import CreationException
from mock import Mock, patch, PropertyMock
from tests.helpers import BaseTestCase, custom_wait, wait_for, DatabaseMock
from core.db.models import Provider
        from flask import Flask
        from core.config import setup_config
            from core.db.models import OpenstackClone
# coding: utf-8





class TestOpenstackCloneUnit(BaseTestCase):
    def setUp(self):
        setup_config('data/config_openstack.py')

        self.app = Flask(__name__)

# Path: core/exceptions.py
# class CreationException(Exception):
#     pass
# 
# Path: tests/helpers.py
# class BaseTestCase(unittest.TestCase):
#     def shortDescription(self):
#         return None
# 
# def custom_wait(self):
#     self.ready = True
#     self.checking = False
#     yield self.ready
# 
# def wait_for(condition, timeout=10):
#     start = time.time()
#     while not condition() and time.time() - start < timeout:
#         time.sleep(0.1)
# 
#     return condition()
# 
# class DatabaseMock(Mock):
#     active_sessions = {}
#     endpoints = {}
# 
#     def __init__(self, *args, **kwargs):
#         super(DatabaseMock, self).__init__(*args, **kwargs)
#         self.add = Mock(side_effect=set_primary_key)
# 
#     def get_active_sessions(self, provider_id=None):
#         return self.active_sessions.values()
# 
#     def get_session(self, session_id):
#         return self.active_sessions.get(str(session_id))
# 
#     def get_endpoint(self, endpoint):
#         pass
# 
#     def get_endpoints(self, *args, **kwargs):
#         return self.endpoints.values()
# 
#     @staticmethod
#     def get_last_session_step(session_id):
#         return Mock()
# 
#     def register_provider(self, name, url, platforms):
#         from core.db.models import Provider
#         return Provider(name, url, platforms)
# 
# Path: core/db/models.py
# class Provider(Base, FeaturesMixin):
#     __tablename__ = 'providers'
# 
#     id = Column(Integer, primary_key=True)
#     name = Column(String(length=200), nullable=True)
#     url = Column(String, nullable=True)
#     active = Column(Boolean, default=False)
#     config = Column(JSON, default={})
#     max_limit = Column(Integer, default=0)
# 
#     def __init__(self, name, url, config=None, active=True, max_limit=0):
#         self.name = name
#         self.url = url
#         self.active = active
#         self.max_limit = max_limit
# 
#         if config:
#             self.config = config
# 
#     @property
#     def info(self):
#         return {
#             "id": self.id,
#             "name": self.name,
#             "url": self.url
#         }


# Path: tests/unit/test_openstack_clone.py
import os
from core.exceptions import CreationException
from mock import Mock, patch, PropertyMock
from tests.helpers import BaseTestCase, custom_wait, wait_for, DatabaseMock
from core.db.models import Provider
        from flask import Flask
        from core.config import setup_config
            from core.db.models import OpenstackClone

# coding: utf-8





class TestOpenstackCloneUnit(BaseTestCase):
    def setUp(self):
        setup_config('data/config_openstack.py')

        self.app = Flask(__name__)

        self.app.database = DatabaseMock()