# 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
                                         'source': {'parameter': '/id'}}

def test_detail_update(dbsession):  # pylint: disable=unused-argument
    """ Update a resource by id. """
    now = datetime.datetime(2017, 8, 7, 18, 42, 49)
    the_model = Horses(id=20, name="qux corge", modified_at=now)
    the_model.save()

    expected = {'data': {'attributes': {'name': 'fizzbuzz'},
                         'id': '20',
                         'links': {'self': '/horses/20'},
                         'meta': {'modified_at': 'Automatically generated, will be replaced.'},
                         'type': 'horses'},
                'links': {'self': '/horses/20'}}

    # id is required for patch
    patch_data = {'data': {'attributes': {'name': 'fizzbuzz'}, 'id': '20', 'type': 'horses'}}
    resource = HorsesResource()
    response = resource.patch(20, patch_data)
    # Correct the timestamp, which we will assume is correct
    expected['data']['meta']['modified_at'] = response['data']['meta']['modified_at']
    assert response == expected

    response = resource.get(20)
    assert response == expected

def test_detail_update_not_found(dbsession):  # pylint: disable=unused-argument
    """ Resource detail Update raises NotFound when id. """
    patch_data = {'data': {'attributes': {'name': 'bad request'}, 'type': 'horses'}}
    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

                                         'source': {'parameter': '/id'}}

def test_detail_update(dbsession):  # pylint: disable=unused-argument
    """ Update a resource by id. """
    now = datetime.datetime(2017, 8, 7, 18, 42, 49)
    the_model = Horses(id=20, name="qux corge", modified_at=now)
    the_model.save()

    expected = {'data': {'attributes': {'name': 'fizzbuzz'},
                         'id': '20',
                         'links': {'self': '/horses/20'},
                         'meta': {'modified_at': 'Automatically generated, will be replaced.'},
                         'type': 'horses'},
                'links': {'self': '/horses/20'}}

    # id is required for patch
    patch_data = {'data': {'attributes': {'name': 'fizzbuzz'}, 'id': '20', 'type': 'horses'}}
    resource = HorsesResource()
    response = resource.patch(20, patch_data)
    # Correct the timestamp, which we will assume is correct
    expected['data']['meta']['modified_at'] = response['data']['meta']['modified_at']
    assert response == expected

    response = resource.get(20)
    assert response == expected

def test_detail_update_not_found(dbsession):  # pylint: disable=unused-argument
    """ Resource detail Update raises NotFound when id. """
    patch_data = {'data': {'attributes': {'name': 'bad request'}, 'type': 'horses'}}
    resource = HorsesResource()

    with pytest.raises(NotFound) as excinfo: