# 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/common/utils.py
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, user_id='', user_name='', data={}):
#     def is_valid(self):
#     def serialize(self):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, action_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, hold_off=30):
#     def update(doc, user_id, session_id):
#     def validate(doc):
#     def create(doc, user_id):
# 
# 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 unittest
from unittest.mock import patch
from freezer_api.common import exceptions
from freezer_api.common import utils
from freezer_api.tests.unit import common

    def test_validate_raises_BadDataFormat_when_doc_has_invalid_state(self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'not_valid'
        self.assertRaises(exceptions.BadDataFormat, utils.JobDoc.validate,
                          job_doc)

    def test_validate_patch_raises_when_doc_has_invalid_state(self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'value_no_allowed'
        self.assertRaises(exceptions.BadDataFormat,
                          utils.JobDoc.validate_patch, job_doc)

    def test_createpatch_pops_jobid_and_userid(self):
        job_doc = common.get_fake_job_0()
        res_doc = utils.JobDoc.create_patch(job_doc)
        self.assertFalse('job_id' in res_doc)
        self.assertFalse('user_id' in res_doc)

    def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_state(
            self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'value_no_allowed'
        self.assertRaises(exceptions.BadDataFormat, utils.JobDoc.create_patch,
                          job_doc)

    def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_event(
            self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['event'] = 'value_no_allowed'

# 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/common/utils.py
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, user_id='', user_name='', data={}):
#     def is_valid(self):
#     def serialize(self):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, action_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, hold_off=30):
#     def update(doc, user_id, session_id):
#     def validate(doc):
#     def create(doc, user_id):
# 
# 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/test_utils.py
import unittest
from unittest.mock import patch
from freezer_api.common import exceptions
from freezer_api.common import utils
from freezer_api.tests.unit import common


    def test_validate_raises_BadDataFormat_when_doc_has_invalid_state(self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'not_valid'
        self.assertRaises(exceptions.BadDataFormat, utils.JobDoc.validate,
                          job_doc)

    def test_validate_patch_raises_when_doc_has_invalid_state(self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'value_no_allowed'
        self.assertRaises(exceptions.BadDataFormat,
                          utils.JobDoc.validate_patch, job_doc)

    def test_createpatch_pops_jobid_and_userid(self):
        job_doc = common.get_fake_job_0()
        res_doc = utils.JobDoc.create_patch(job_doc)
        self.assertFalse('job_id' in res_doc)
        self.assertFalse('user_id' in res_doc)

    def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_state(
            self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['status'] = 'value_no_allowed'
        self.assertRaises(exceptions.BadDataFormat, utils.JobDoc.create_patch,
                          job_doc)

    def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_event(
            self):
        job_doc = common.get_fake_job_0()
        job_doc['job_schedule']['event'] = 'value_no_allowed'

        self.assertRaises(exceptions.BadDataFormat, utils.JobDoc.create_patch,