# 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 Forbidden(JSONAPIError, werkzeug.exceptions.Forbidden):
#     """ 403 Forbidden: unsupported request to create, update, delete resource or relationship. """
#     pass


    from builtins import *  # pylint: disable=unused-wildcard-import,redefined-builtin,wildcard-import
from models import bases
from ourapi.exceptions import Forbidden
    import sys
import datetime
import warnings
import flask
import pytest
import sqlalchemy as sa
import ourapi
import ourmarshmallow
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    resource = BatteriesResource()
    # Need to create a flask app and context so post can generate the URL for new model.
    test_app = flask.Flask(__name__)
    test_app.add_url_rule('/batteries/<int:model_id>',
                          view_func=BatteriesResource.as_view(BatteriesResource.__name__))

    post_data = {'data': {'attributes': {'charge': 88.96770429362424}, 'type': 'batteries'}}
    with test_app.test_request_context():
        response, code, headers = resource.post(post_data)

    assert code == 201
    assert headers == {'Location': '/batteries/1'}
    assert response == {'data': {'attributes': {'charge': 88.96770429362424},
                                 'id': '1',
                                 'links': {'self': '/batteries/1'},
                                 # Correct the timestamp, which we will assume is correct
                                 'meta': {'modified_at': response['data']['meta']['modified_at']},
                                 'type': 'batteries'},
                        'links': {'self': '/batteries/1'}}

def test_create_id_conflict(dbsession):  # pylint: disable=unused-argument
    """
    ourapi doesn't support client generated ids.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    resource = BatteriesResource()
    post_data = {'data': {'attributes': {'charge': 67.88553490220708}, 'type': 'batteries',
                          'id': '50'}}

# 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 Forbidden(JSONAPIError, werkzeug.exceptions.Forbidden):
#     """ 403 Forbidden: unsupported request to create, update, delete resource or relationship. """
#     pass


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

    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    resource = BatteriesResource()
    # Need to create a flask app and context so post can generate the URL for new model.
    test_app = flask.Flask(__name__)
    test_app.add_url_rule('/batteries/<int:model_id>',
                          view_func=BatteriesResource.as_view(BatteriesResource.__name__))

    post_data = {'data': {'attributes': {'charge': 88.96770429362424}, 'type': 'batteries'}}
    with test_app.test_request_context():
        response, code, headers = resource.post(post_data)

    assert code == 201
    assert headers == {'Location': '/batteries/1'}
    assert response == {'data': {'attributes': {'charge': 88.96770429362424},
                                 'id': '1',
                                 'links': {'self': '/batteries/1'},
                                 # Correct the timestamp, which we will assume is correct
                                 'meta': {'modified_at': response['data']['meta']['modified_at']},
                                 'type': 'batteries'},
                        'links': {'self': '/batteries/1'}}

def test_create_id_conflict(dbsession):  # pylint: disable=unused-argument
    """
    ourapi doesn't support client generated ids.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    resource = BatteriesResource()
    post_data = {'data': {'attributes': {'charge': 67.88553490220708}, 'type': 'batteries',
                          'id': '50'}}

    with pytest.raises(Forbidden) as excinfo: