# Path: habitat/views/payload_configuration.py
# def _validate_ukhas(sentence):
# def _validate_modulation_settings(transmission):
# def _validate_filter(f):
# def validate(new, old, userctx, secobj):
# def name_time_created_map(doc):
# def callsign_time_created_index_map(doc):
# 
# Path: habitat/views/utils.py
# def read_json_schema(schemaname):
#     mypath = os.path.dirname(inspect.getfile(inspect.currentframe()))
#     path = os.path.join(mypath, "..", "..", "couchdb", "schemas", schemaname)
#     with open(path) as f:
#         schema = json.load(f)
#     return schema


from ...views import payload_configuration
from ...views.utils import read_json_schema
from couch_named_python import ForbiddenError, UnauthorizedError
from copy import deepcopy
from nose.tools import assert_raises
import mox
                        "type": "normal",
                        "filter": "a.b.c"
                    }
                ],
                "post": [
                    {
                        "type": "hotfix",
                        "code": "test",
                        "signature": "test",
                        "certificate": "test"
                    }
                ]
            }
        }
    ]
}

schema = read_json_schema("payload_configuration.json")

class TestPayloadConfiguration(object):
    def setup(self):
        self.m = mox.Mox()
        self.m.StubOutWithMock(payload_configuration, 'validate_doc')

    def teardown(self):
        self.m.UnsetStubs()
    
    def test_validates_against_schema(self):
        payload_configuration.validate_doc(doc, schema)
        self.m.ReplayAll()

# Path: habitat/views/payload_configuration.py
# def _validate_ukhas(sentence):
# def _validate_modulation_settings(transmission):
# def _validate_filter(f):
# def validate(new, old, userctx, secobj):
# def name_time_created_map(doc):
# def callsign_time_created_index_map(doc):
# 
# Path: habitat/views/utils.py
# def read_json_schema(schemaname):
#     mypath = os.path.dirname(inspect.getfile(inspect.currentframe()))
#     path = os.path.join(mypath, "..", "..", "couchdb", "schemas", schemaname)
#     with open(path) as f:
#         schema = json.load(f)
#     return schema


# Path: habitat/tests/test_views/test_payload_configuration.py
from ...views import payload_configuration
from ...views.utils import read_json_schema
from couch_named_python import ForbiddenError, UnauthorizedError
from copy import deepcopy
from nose.tools import assert_raises
import mox

                        "type": "normal",
                        "filter": "a.b.c"
                    }
                ],
                "post": [
                    {
                        "type": "hotfix",
                        "code": "test",
                        "signature": "test",
                        "certificate": "test"
                    }
                ]
            }
        }
    ]
}

schema = read_json_schema("payload_configuration.json")

class TestPayloadConfiguration(object):
    def setup(self):
        self.m = mox.Mox()
        self.m.StubOutWithMock(payload_configuration, 'validate_doc')

    def teardown(self):
        self.m.UnsetStubs()
    
    def test_validates_against_schema(self):
        payload_configuration.validate_doc(doc, schema)
        self.m.ReplayAll()

        payload_configuration.validate(doc, {}, {'roles': []}, {})