Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions flask_combo_jsonapi/data_layers/alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from sqlalchemy.inspection import inspect
from sqlalchemy.orm.attributes import QueryableAttribute
from sqlalchemy.orm import joinedload, ColumnProperty, RelationshipProperty
from marshmallow import class_registry
from marshmallow.base import SchemaABC
from marshmallow import class_registry, Schema

from flask_combo_jsonapi.data_layers.base import BaseDataLayer
from flask_combo_jsonapi.data_layers.sorting.alchemy import create_sorts
Expand Down Expand Up @@ -683,7 +682,7 @@ def eagerload_includes(self, query, qs):

related_schema_cls = get_related_schema(current_schema, obj)

if isinstance(related_schema_cls, SchemaABC):
if isinstance(related_schema_cls, Schema):
related_schema_cls = related_schema_cls.__class__
else:
related_schema_cls = class_registry.get_class(related_schema_cls)
Expand Down
5 changes: 2 additions & 3 deletions flask_combo_jsonapi/schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Helpers to deal with marshmallow schemas"""
from collections import OrderedDict

from marshmallow import class_registry
from marshmallow.base import SchemaABC
from marshmallow import class_registry, Schema
from marshmallow_jsonapi.fields import Relationship, List, Nested

from flask_combo_jsonapi.exceptions import InvalidInclude
Expand Down Expand Up @@ -70,7 +69,7 @@ def compute_schema(schema_cls, default_kwargs, qs, include):
related_schema_kwargs = {}
if 'context' in default_kwargs:
related_schema_kwargs['context'] = default_kwargs['context']
if isinstance(related_schema_cls, SchemaABC):
if isinstance(related_schema_cls, Schema):
related_schema_kwargs['many'] = related_schema_cls.many
related_schema_kwargs['include_data'] = related_schema_cls.__dict__.get('include_data')
related_schema_cls = related_schema_cls.__class__
Expand Down
15 changes: 3 additions & 12 deletions tests/test_sqlalchemy_data_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def address_schema():
class AddressSchema(MarshmallowSchema):
street = fields.String(required=True)
city = fields.String(required=True)
state = fields.String(missing="NC")
state = fields.String(load_default="NC")
zip = fields.String(required=True)

yield AddressSchema
Expand Down Expand Up @@ -401,8 +401,8 @@ class Meta:
serial = fields.Str(required=True)
owner = Relationship(
attribute="person",
default=None,
missing=None,
dump_default=None,
load_default=None,
related_view="api.person_detail",
related_view_kwargs={"person_id": "<person.person_id>"},
schema="PersonSchema",
Expand Down Expand Up @@ -819,15 +819,6 @@ def test_compute_schema(person_schema):
flask_combo_jsonapi.schema.compute_schema(person_schema, dict(only=list()), qsm, list())


def test_compute_schema_propagate_context(person_schema, computer_schema):
query_string = {}
qsm = QSManager(query_string, person_schema)
schema = flask_combo_jsonapi.schema.compute_schema(person_schema, dict(), qsm, ["computers"])
assert schema.declared_fields["computers"].__dict__["_Relationship__schema"].__dict__["context"] == dict()
schema = flask_combo_jsonapi.schema.compute_schema(person_schema, dict(context=dict(foo="bar")), qsm, ["computers"])
assert schema.declared_fields["computers"].__dict__["_Relationship__schema"].__dict__["context"] == dict(foo="bar")


# test good cases
def test_get_list(client, register_routes, person, person_2):
with client:
Expand Down
Loading