# 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
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()
    response = resource.get(22)
    # Just above this section is an example a related resource request returning nothing:
    # http://jsonapi.org/format/#fetching-resources-responses-404
    assert response == {'data': [], 'links': {'related': '/departments/22/children',
                                              'self': '/departments/22/relationships/children'}}

def test_read_to_many_relationship(dbsession, testdata):  # pylint: disable=unused-argument,redefined-outer-name
    """
    Read a to many relationships.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()
    response = resource.get(20)
    assert response == {'data': [{'id': '21', 'type': 'departments'},
                                 {'id': '22', 'type': 'departments'}],
                        'links': {'related': '/departments/20/children',
                                  'self': '/departments/20/relationships/children'}}

def test_model_missing_relationship(dbsession, testdata):  # pylint: disable=unused-argument,redefined-outer-name
    """
    Model ID 999 doesn't exist so this should return a 404 Not Found exception.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()

# 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_relationships.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

    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()
    response = resource.get(22)
    # Just above this section is an example a related resource request returning nothing:
    # http://jsonapi.org/format/#fetching-resources-responses-404
    assert response == {'data': [], 'links': {'related': '/departments/22/children',
                                              'self': '/departments/22/relationships/children'}}

def test_read_to_many_relationship(dbsession, testdata):  # pylint: disable=unused-argument,redefined-outer-name
    """
    Read a to many relationships.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()
    response = resource.get(20)
    assert response == {'data': [{'id': '21', 'type': 'departments'},
                                 {'id': '22', 'type': 'departments'}],
                        'links': {'related': '/departments/20/children',
                                  'self': '/departments/20/relationships/children'}}

def test_model_missing_relationship(dbsession, testdata):  # pylint: disable=unused-argument,redefined-outer-name
    """
    Model ID 999 doesn't exist so this should return a 404 Not Found exception.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    :param list(str) testdata: pytest fixture listing test data tokens.
    """
    resource = ChildrenRelationship()

    with pytest.raises(NotFound):