# Path: freezer_api/api/v1/actions.py
# class ActionsCollectionResource(resource.BaseResource):
# class ActionsResource(resource.BaseResource):
#     def __init__(self, storage_driver):
#     def on_get(self, req, resp):
#     def on_post(self, req, resp):
#     def __init__(self, storage_driver):
#     def on_get(self, req, resp, action_id):
#     def on_delete(self, req, resp, action_id):
#     def on_patch(self, req, resp, action_id):
#     def on_post(self, req, resp, action_id):
# 
# 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):


import random
import falcon
from unittest import mock
from freezer_api.api.v1 import actions as v1_actions
from freezer_api.common import exceptions
from freezer_api.tests.unit import common
                           'version': new_version}

        self.resource.on_patch(self.mock_req, self.mock_req,
                               common.fake_action_0['action_id'])
        self.mock_db.update_action.assert_called_with(
            user_id=common.fake_action_0['user_id'],
            action_id=common.fake_action_0['action_id'],
            patch_doc=patch_doc)
        self.assertEqual(falcon.HTTP_200, self.mock_req.status)
        result = self.mock_req.body
        self.assertEqual(expected_result, result)

    def test_on_post_ok(self):
        new_version = random.randint(0, 99)
        self.mock_db.replace_action.return_value = new_version
        action = common.get_fake_action_0()
        self.mock_json_body.return_value = action
        expected_result = {'action_id': common.fake_action_0['action_id'],
                           'version': new_version}

        self.resource.on_post(self.mock_req, self.mock_req,
                              common.fake_action_0['action_id'])
        self.assertEqual(falcon.HTTP_201, self.mock_req.status)
        self.assertEqual(expected_result, self.mock_req.body)

    def test_on_post_raises_when_db_replace_action_raises(self):
        self.mock_db.replace_action.side_effect = exceptions.AccessForbidden(
            'regular test failure')
        action = common.get_fake_action_0()
        self.mock_json_body.return_value = action

# Path: freezer_api/api/v1/actions.py
# class ActionsCollectionResource(resource.BaseResource):
# class ActionsResource(resource.BaseResource):
#     def __init__(self, storage_driver):
#     def on_get(self, req, resp):
#     def on_post(self, req, resp):
#     def __init__(self, storage_driver):
#     def on_get(self, req, resp, action_id):
#     def on_delete(self, req, resp, action_id):
#     def on_patch(self, req, resp, action_id):
#     def on_post(self, req, resp, action_id):
# 
# 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/v1/test_actions.py
import random
import falcon
from unittest import mock
from freezer_api.api.v1 import actions as v1_actions
from freezer_api.common import exceptions
from freezer_api.tests.unit import common

                           'version': new_version}

        self.resource.on_patch(self.mock_req, self.mock_req,
                               common.fake_action_0['action_id'])
        self.mock_db.update_action.assert_called_with(
            user_id=common.fake_action_0['user_id'],
            action_id=common.fake_action_0['action_id'],
            patch_doc=patch_doc)
        self.assertEqual(falcon.HTTP_200, self.mock_req.status)
        result = self.mock_req.body
        self.assertEqual(expected_result, result)

    def test_on_post_ok(self):
        new_version = random.randint(0, 99)
        self.mock_db.replace_action.return_value = new_version
        action = common.get_fake_action_0()
        self.mock_json_body.return_value = action
        expected_result = {'action_id': common.fake_action_0['action_id'],
                           'version': new_version}

        self.resource.on_post(self.mock_req, self.mock_req,
                              common.fake_action_0['action_id'])
        self.assertEqual(falcon.HTTP_201, self.mock_req.status)
        self.assertEqual(expected_result, self.mock_req.body)

    def test_on_post_raises_when_db_replace_action_raises(self):
        self.mock_db.replace_action.side_effect = exceptions.AccessForbidden(
            'regular test failure')
        action = common.get_fake_action_0()
        self.mock_json_body.return_value = action

        self.assertRaises(exceptions.AccessForbidden, self.resource.on_post,