# 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
        self.mock_db.get_action.return_value = common.get_fake_action_0()
        self.resource.on_get(self.mock_req, self.mock_req,
                             common.fake_action_0['action_id'])
        result = self.mock_req.body
        self.assertEqual(common.get_fake_action_0(), result)
        self.assertEqual(falcon.HTTP_200, self.mock_req.status)

    def test_on_delete_removes_proper_data(self):
        self.resource.on_delete(self.mock_req, self.mock_req,
                                common.fake_action_0['action_id'])
        result = self.mock_req.body
        expected_result = {'action_id': common.fake_action_0['action_id']}
        self.assertEqual(falcon.HTTP_204, self.mock_req.status)
        self.assertEqual(expected_result, result)

    def test_on_patch_ok_with_some_fields(self):
        new_version = random.randint(0, 99)
        self.mock_db.update_action.return_value = new_version
        patch_doc = {'some_field': 'some_value',
                     'because': 'size_matters'}
        self.mock_json_body.return_value = patch_doc

        patch_doc.copy()

        expected_result = {'action_id': common.fake_action_0['action_id'],
                           '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(

# 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

        self.mock_db.get_action.return_value = common.get_fake_action_0()
        self.resource.on_get(self.mock_req, self.mock_req,
                             common.fake_action_0['action_id'])
        result = self.mock_req.body
        self.assertEqual(common.get_fake_action_0(), result)
        self.assertEqual(falcon.HTTP_200, self.mock_req.status)

    def test_on_delete_removes_proper_data(self):
        self.resource.on_delete(self.mock_req, self.mock_req,
                                common.fake_action_0['action_id'])
        result = self.mock_req.body
        expected_result = {'action_id': common.fake_action_0['action_id']}
        self.assertEqual(falcon.HTTP_204, self.mock_req.status)
        self.assertEqual(expected_result, result)

    def test_on_patch_ok_with_some_fields(self):
        new_version = random.randint(0, 99)
        self.mock_db.update_action.return_value = new_version
        patch_doc = {'some_field': 'some_value',
                     'because': 'size_matters'}
        self.mock_json_body.return_value = patch_doc

        patch_doc.copy()

        expected_result = {'action_id': common.fake_action_0['action_id'],
                           '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'],