# Path: models/bases.py
# NO_VALUE = sa_symbol('NO_VALUE')
# class Base(object):
# class BaseModel(Base):
#     def __repr__(self):
#     def __str__(self):
#     def __tablename__(cls):  # pylint: disable=no-self-argument
#     def delete(self):
#     def _prepare_conditions(cls, conditions):
#     def get_all(cls, conditions=None):
#     def get_by_pk(cls, the_id):
#     def save(self, flush=False):
# 
# Path: ourapi/exceptions.py
# class Conflict(JSONAPIError, werkzeug.exceptions.Conflict):
#     """ 409 Conflict: fails server unique constraint or id issues. """
#     pass
# 
# class NotFound(JSONAPIError, werkzeug.exceptions.NotFound):
#     """ 404 Not Found: Resource doesn't exist. """
#     pass


    from builtins import *  # pylint: disable=unused-wildcard-import,redefined-builtin,wildcard-import
from models import bases
from ourapi.exceptions import Conflict, NotFound
    import sys
import datetime
import warnings
import marshmallow
import pytest
import sqlalchemy as sa
import ourapi
import ourmarshmallow
            # This will be turned into a BadRequest by the error handler in the API.
        resource.patch(30, patch_data)

    assert excinfo.value.messages == {'errors': [{'detail': '`data` object must include `id` key.',
                                                  'source': {'pointer': '/data'}}]}

def test_detail_update_id_mismatch(dbsession):  # pylint: disable=unused-argument
    """ Payload id and URL id must match for patch/update """
    the_model = Horses(id=40, name="Madden Everything Wonder Pronunciation")
    the_model.save()

    # id does not match the request url id
    patch_data = {'data': {'attributes': {'name': 'bad request'},
                           'id': '999', 'type': 'horses'}}
    resource = HorsesResource()
    with pytest.raises(Conflict) as excinfo:
        resource.patch(40, patch_data)

    assert excinfo.value.description == {'detail': 'Mismatched id. Expected "40".',
                                         'source': {'pointer': '/data/id'}}

def test_detail_update_type_mismatch(dbsession):  # pylint: disable=unused-argument,invalid-name
    """ Payload type and URL must match for patch/update """
    the_model = Horses(id=50, name="Ordinary Know Scent Advice")
    the_model.save()

    # id does not match the request url id
    patch_data = {'data': {'attributes': {'name': 'bad request'},
                           'id': '50', 'type': 'batteries'}}
    resource = HorsesResource()

# Path: models/bases.py
# NO_VALUE = sa_symbol('NO_VALUE')
# class Base(object):
# class BaseModel(Base):
#     def __repr__(self):
#     def __str__(self):
#     def __tablename__(cls):  # pylint: disable=no-self-argument
#     def delete(self):
#     def _prepare_conditions(cls, conditions):
#     def get_all(cls, conditions=None):
#     def get_by_pk(cls, the_id):
#     def save(self, flush=False):
# 
# Path: ourapi/exceptions.py
# class Conflict(JSONAPIError, werkzeug.exceptions.Conflict):
#     """ 409 Conflict: fails server unique constraint or id issues. """
#     pass
# 
# class NotFound(JSONAPIError, werkzeug.exceptions.NotFound):
#     """ 404 Not Found: Resource doesn't exist. """
#     pass


# Path: tests/ourapi/test_resource_detail.py
    from builtins import *  # pylint: disable=unused-wildcard-import,redefined-builtin,wildcard-import
from models import bases
from ourapi.exceptions import Conflict, NotFound
    import sys
import datetime
import warnings
import marshmallow
import pytest
import sqlalchemy as sa
import ourapi
import ourmarshmallow

            # This will be turned into a BadRequest by the error handler in the API.
        resource.patch(30, patch_data)

    assert excinfo.value.messages == {'errors': [{'detail': '`data` object must include `id` key.',
                                                  'source': {'pointer': '/data'}}]}

def test_detail_update_id_mismatch(dbsession):  # pylint: disable=unused-argument
    """ Payload id and URL id must match for patch/update """
    the_model = Horses(id=40, name="Madden Everything Wonder Pronunciation")
    the_model.save()

    # id does not match the request url id
    patch_data = {'data': {'attributes': {'name': 'bad request'},
                           'id': '999', 'type': 'horses'}}
    resource = HorsesResource()
    with pytest.raises(Conflict) as excinfo:
        resource.patch(40, patch_data)

    assert excinfo.value.description == {'detail': 'Mismatched id. Expected "40".',
                                         'source': {'pointer': '/data/id'}}

def test_detail_update_type_mismatch(dbsession):  # pylint: disable=unused-argument,invalid-name
    """ Payload type and URL must match for patch/update """
    the_model = Horses(id=50, name="Ordinary Know Scent Advice")
    the_model.save()

    # id does not match the request url id
    patch_data = {'data': {'attributes': {'name': 'bad request'},
                           'id': '50', 'type': 'batteries'}}
    resource = HorsesResource()

    with pytest.raises(Conflict) as excinfo: