# Path: habitat/views/listener_information.py
# def validate(new, old, userctx, secobj):
# def time_created_callsign_map(doc):
# def callsign_time_created_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 listener_information
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
"""
Tests listener_information document views and functions.
"""





doc = {
    "type": "listener_information",
    "time_created": "2012-07-17T21:03:26+01:00",
    "time_uploaded": "2012-07-17T21:03:29+01:00",
    "data": {
        "callsign": "M0RND",
        "antenna": "2m/70cm Colinear",
        "radio": "ICOM IC-7000"
    }
}

schema = read_json_schema("listener_information.json")

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

    def teardown(self):
        self.m.UnsetStubs()
    
    def test_validates_against_schema(self):

# Path: habitat/views/listener_information.py
# def validate(new, old, userctx, secobj):
# def time_created_callsign_map(doc):
# def callsign_time_created_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_listener_information.py
from ...views import listener_information
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

"""
Tests listener_information document views and functions.
"""





doc = {
    "type": "listener_information",
    "time_created": "2012-07-17T21:03:26+01:00",
    "time_uploaded": "2012-07-17T21:03:29+01:00",
    "data": {
        "callsign": "M0RND",
        "antenna": "2m/70cm Colinear",
        "radio": "ICOM IC-7000"
    }
}

schema = read_json_schema("listener_information.json")

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

    def teardown(self):
        self.m.UnsetStubs()
    
    def test_validates_against_schema(self):

        listener_information.validate_doc(doc, schema)