# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
# 
# Path: freezer_api/tests/unit/common.py
# CONF = cfg.CONF
# def get_fake_backup_metadata():
# def get_fake_job_0():
# def get_fake_job_1():
# def get_fake_job_2():
# def get_fake_job_3():
# def get_fake_job_id():
# def get_fake_client_0():
# def get_fake_client_1():
# def get_fake_client_id():
# def get_fake_action_0():
# def get_fake_action_1():
# def get_fake_action_2():
# def get_fake_action_id():
# def get_fake_action_3():
# def get_fake_session_0():
# def get_fake_session_1():
# def get_fake_session_2():
# def get_fake_session_3():
# def get_fake_session_id():
#     def __init__(self, method='GET', body=''):
#     def get_header(self, key):
#     def setUp(self):
#     def __init__(self, *args, **kwargs):
#     def to_dict(self):
# def get_req_items(name):
# class FakeReqResp(object):
# class FreezerBaseTestCase(testtools.TestCase):
# class FakeContext(object):
# 
# Path: freezer_api/tests/unit/sqlalchemy/base.py
# CONF = cfg.CONF
# _DB_CACHE = None
# IN_MEM_DB_CONN_STRING = 'sqlite://'
#             _DB_CACHE = Database(sqla_api)
# class Database(fixtures.Fixture):
# class DbTestCase(common.FreezerBaseTestCase):
#     def __init__(self, db_api):
#     def initialize_sql_session(self, connection_str):
#     def setup_sqlite(self):
#     def setUp(self):
#     def setUp(self):


import copy
from unittest import mock
from unittest.mock import patch
from freezer_api.common import exceptions as freezer_api_exc
from freezer_api.tests.unit import common
from freezer_api.tests.unit.sqlalchemy import base
            count += 1

        result = self.dbapi.search_backup(project_id=self.fake_project_id,
                                          user_id=self.fake_user_id,
                                          limit=10,
                                          offset=0)

        self.assertIsNotNone(result)

        self.assertEqual(len(result), 10)

        for index in range(len(result)):
            backupmap = result[index]
            self.assertEqual(backupids[index], backupmap['backup_id'])

    @patch('freezer_api.db.sqlalchemy.api.get_backup')
    def test_raise_add_backup_exist(self, mock_get_backup):
        mock_get_backup.return_value = mock.MagicMock()
        self.assertRaises(freezer_api_exc.DocumentExists,
                          self.dbapi.add_backup, self.fake_user_id,
                          '12343', self.fake_backup_metadata,
                          project_id=self.fake_project_id)

    @patch('freezer_api.common.elasticv2_utils.BackupMetadataDoc')
    @patch('freezer_api.common.utils.BackupMetadataDoc')
    def test_raise_add_backup(self, mock1_BackupMetadataDoc,
                              mock_BackupMetadataDoc):
        mock1_BackupMetadataDoc().is_valid.return_value = None
        mock_BackupMetadataDoc().is_valid.return_value = None
        mock_doc = mock.MagicMock()

# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
# 
# Path: freezer_api/tests/unit/common.py
# CONF = cfg.CONF
# def get_fake_backup_metadata():
# def get_fake_job_0():
# def get_fake_job_1():
# def get_fake_job_2():
# def get_fake_job_3():
# def get_fake_job_id():
# def get_fake_client_0():
# def get_fake_client_1():
# def get_fake_client_id():
# def get_fake_action_0():
# def get_fake_action_1():
# def get_fake_action_2():
# def get_fake_action_id():
# def get_fake_action_3():
# def get_fake_session_0():
# def get_fake_session_1():
# def get_fake_session_2():
# def get_fake_session_3():
# def get_fake_session_id():
#     def __init__(self, method='GET', body=''):
#     def get_header(self, key):
#     def setUp(self):
#     def __init__(self, *args, **kwargs):
#     def to_dict(self):
# def get_req_items(name):
# class FakeReqResp(object):
# class FreezerBaseTestCase(testtools.TestCase):
# class FakeContext(object):
# 
# Path: freezer_api/tests/unit/sqlalchemy/base.py
# CONF = cfg.CONF
# _DB_CACHE = None
# IN_MEM_DB_CONN_STRING = 'sqlite://'
#             _DB_CACHE = Database(sqla_api)
# class Database(fixtures.Fixture):
# class DbTestCase(common.FreezerBaseTestCase):
#     def __init__(self, db_api):
#     def initialize_sql_session(self, connection_str):
#     def setup_sqlite(self):
#     def setUp(self):
#     def setUp(self):


# Path: freezer_api/tests/unit/sqlalchemy/v2/test_backup.py
import copy
from unittest import mock
from unittest.mock import patch
from freezer_api.common import exceptions as freezer_api_exc
from freezer_api.tests.unit import common
from freezer_api.tests.unit.sqlalchemy import base

            count += 1

        result = self.dbapi.search_backup(project_id=self.fake_project_id,
                                          user_id=self.fake_user_id,
                                          limit=10,
                                          offset=0)

        self.assertIsNotNone(result)

        self.assertEqual(len(result), 10)

        for index in range(len(result)):
            backupmap = result[index]
            self.assertEqual(backupids[index], backupmap['backup_id'])

    @patch('freezer_api.db.sqlalchemy.api.get_backup')
    def test_raise_add_backup_exist(self, mock_get_backup):
        mock_get_backup.return_value = mock.MagicMock()
        self.assertRaises(freezer_api_exc.DocumentExists,
                          self.dbapi.add_backup, self.fake_user_id,
                          '12343', self.fake_backup_metadata,
                          project_id=self.fake_project_id)

    @patch('freezer_api.common.elasticv2_utils.BackupMetadataDoc')
    @patch('freezer_api.common.utils.BackupMetadataDoc')
    def test_raise_add_backup(self, mock1_BackupMetadataDoc,
                              mock_BackupMetadataDoc):
        mock1_BackupMetadataDoc().is_valid.return_value = None
        mock_BackupMetadataDoc().is_valid.return_value = None
        mock_doc = mock.MagicMock()

        self.assertRaises(freezer_api_exc.BadDataFormat,