# Path: tests/helpers.py
# def assert_raises_with_message(
#     exception_type, message, function, *args, **kwargs):
#     """Assert that a function raises an exception with :param message: as its
#     message.
#     """
#     try:
#         function(*args, **kwargs)
#     except exception_type as ex:
#         if str(ex) != message:
#             raise AssertionError(
#                 'Expected {0} with message of {1}, but message was {2}'
#                 .format(exception_type.__name__, repr(message), repr(str(ex))))
#         return
#     raise AssertionError('{0} not raised'.format(exception_type.__name__))


import datetime
import scalymongo.schema as mod
from dingus import Dingus, DingusTestCase, DontCare
from nose.tools import assert_raises
from scalymongo.schema import *
from tests.helpers import assert_raises_with_message
        assert mod.StructureWalker().calls(
            'walk_dict', self.body, self.structure)


## validate_single_field ##


class DescribeValidateSingleField(
    DingusTestCase(validate_single_field, ['ValidationError'])):

    def setup(self):
        super(DescribeValidateSingleField, self).setup()
        self.path = Dingus('path')
        self.value = Dingus('value')
        self.expected_type = Dingus('expected_type')


class WhenFieldIsExpectedType(DescribeValidateSingleField):

    def setup(self):
        DescribeValidateSingleField.setup(self)
        mod.is_field_of_expected_type.return_value = True

    def should_not_crash(self):
        validate_single_field(self.path, self.value, self.expected_type)


class WhenFieldIsNotExpectedType(DescribeValidateSingleField):

    def setup(self):

# Path: tests/helpers.py
# def assert_raises_with_message(
#     exception_type, message, function, *args, **kwargs):
#     """Assert that a function raises an exception with :param message: as its
#     message.
#     """
#     try:
#         function(*args, **kwargs)
#     except exception_type as ex:
#         if str(ex) != message:
#             raise AssertionError(
#                 'Expected {0} with message of {1}, but message was {2}'
#                 .format(exception_type.__name__, repr(message), repr(str(ex))))
#         return
#     raise AssertionError('{0} not raised'.format(exception_type.__name__))


# Path: tests/unit/test_schema.py
import datetime
import scalymongo.schema as mod
from dingus import Dingus, DingusTestCase, DontCare
from nose.tools import assert_raises
from scalymongo.schema import *
from tests.helpers import assert_raises_with_message

        assert mod.StructureWalker().calls(
            'walk_dict', self.body, self.structure)


## validate_single_field ##


class DescribeValidateSingleField(
    DingusTestCase(validate_single_field, ['ValidationError'])):

    def setup(self):
        super(DescribeValidateSingleField, self).setup()
        self.path = Dingus('path')
        self.value = Dingus('value')
        self.expected_type = Dingus('expected_type')


class WhenFieldIsExpectedType(DescribeValidateSingleField):

    def setup(self):
        DescribeValidateSingleField.setup(self)
        mod.is_field_of_expected_type.return_value = True

    def should_not_crash(self):
        validate_single_field(self.path, self.value, self.expected_type)


class WhenFieldIsNotExpectedType(DescribeValidateSingleField):

    def setup(self):

        DescribeValidateSingleField.setup(self)