# Path: freezer_api/api/v1/jobs.py
# class JobsBaseResource(resource.BaseResource):
# class JobsCollectionResource(JobsBaseResource):
# class JobsResource(JobsBaseResource):
# class JobsEvent(resource.BaseResource):
# class Action(object):
# class Job(object):
#     def __init__(self, storage_driver):
#     def get_action(self, user_id, action_id):
#     def update_actions_in_job(self, user_id, job_doc):
#     def on_get(self, req, resp):
#     def on_post(self, req, resp):
#     def on_get(self, req, resp, job_id):
#     def on_delete(self, req, resp, job_id):
#     def on_patch(self, req, resp, job_id):
#     def on_post(self, req, resp, job_id):
#     def __init__(self, storage_driver):
#     def on_post(self, req, resp, job_id):
#     def __init__(self, doc):
#     def action_id(self):
#     def action_id(self, value):
#     def create_new_action_id(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, doc):
#     def execute_event(self, event, params):
#     def job_status(self):
#     def job_status(self, value):
#     def start(self, params=None):
#     def stop(self, params=None):
#     def abort(self, params=None):
#     def actions(self):
#     def expand_default_properties(self):
# 
# 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 unittest.mock import patch
from oslo_serialization import jsonutils as json
from freezer_api.api.v1 import jobs as v1_jobs
from freezer_api.common import exceptions
from freezer_api.tests.unit import common
                             event='abort',
                             response='abort already requested',
                             need_update=False)

    def test_abort_nostatus_unaborted_job(self):
        self._test_job_abort(status=None,
                             event=None,
                             response='success',
                             need_update=True)

    @patch.object(v1_jobs.Job, 'start')
    def test_execute_start_event(self, mock_start):
        job = v1_jobs.Job({})
        job.execute_event('start', 'my_params')
        mock_start.assert_called_once_with('my_params')

    @patch.object(v1_jobs.Job, 'stop')
    def test_execute_stop_event(self, mock_stop):
        job = v1_jobs.Job({})
        job.execute_event('stop', 'my_params')
        mock_stop.assert_called_once_with('my_params')

    @patch.object(v1_jobs.Job, 'abort')
    def test_execute_abort_event(self, mock_abort):
        job = v1_jobs.Job({})
        job.execute_event('abort', 'my_params')
        mock_abort.assert_called_once_with('my_params')

    def test_execute_raises_BadDataFormat_when_event_not_implemented(self):
        job = v1_jobs.Job({})

# Path: freezer_api/api/v1/jobs.py
# class JobsBaseResource(resource.BaseResource):
# class JobsCollectionResource(JobsBaseResource):
# class JobsResource(JobsBaseResource):
# class JobsEvent(resource.BaseResource):
# class Action(object):
# class Job(object):
#     def __init__(self, storage_driver):
#     def get_action(self, user_id, action_id):
#     def update_actions_in_job(self, user_id, job_doc):
#     def on_get(self, req, resp):
#     def on_post(self, req, resp):
#     def on_get(self, req, resp, job_id):
#     def on_delete(self, req, resp, job_id):
#     def on_patch(self, req, resp, job_id):
#     def on_post(self, req, resp, job_id):
#     def __init__(self, storage_driver):
#     def on_post(self, req, resp, job_id):
#     def __init__(self, doc):
#     def action_id(self):
#     def action_id(self, value):
#     def create_new_action_id(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, doc):
#     def execute_event(self, event, params):
#     def job_status(self):
#     def job_status(self, value):
#     def start(self, params=None):
#     def stop(self, params=None):
#     def abort(self, params=None):
#     def actions(self):
#     def expand_default_properties(self):
# 
# 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_jobs.py
import random
import falcon
from unittest import mock
from unittest.mock import patch
from oslo_serialization import jsonutils as json
from freezer_api.api.v1 import jobs as v1_jobs
from freezer_api.common import exceptions
from freezer_api.tests.unit import common

                             event='abort',
                             response='abort already requested',
                             need_update=False)

    def test_abort_nostatus_unaborted_job(self):
        self._test_job_abort(status=None,
                             event=None,
                             response='success',
                             need_update=True)

    @patch.object(v1_jobs.Job, 'start')
    def test_execute_start_event(self, mock_start):
        job = v1_jobs.Job({})
        job.execute_event('start', 'my_params')
        mock_start.assert_called_once_with('my_params')

    @patch.object(v1_jobs.Job, 'stop')
    def test_execute_stop_event(self, mock_stop):
        job = v1_jobs.Job({})
        job.execute_event('stop', 'my_params')
        mock_stop.assert_called_once_with('my_params')

    @patch.object(v1_jobs.Job, 'abort')
    def test_execute_abort_event(self, mock_abort):
        job = v1_jobs.Job({})
        job.execute_event('abort', 'my_params')
        mock_abort.assert_called_once_with('my_params')

    def test_execute_raises_BadDataFormat_when_event_not_implemented(self):
        job = v1_jobs.Job({})

        self.assertRaises(exceptions.BadDataFormat, job.execute_event, 'smile',