Skip to content

Commit f65f7ba

Browse files
committed
updated test case
1 parent 4cf51c5 commit f65f7ba

File tree

2 files changed

+55
-55
lines changed

2 files changed

+55
-55
lines changed

tests/fixtures/app.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
ListViewBaseGeneric,
1616
)
1717
from tests.models import (
18+
Alpha,
19+
Beta,
1820
Child,
1921
Computer,
2022
CustomUUIDItem,
23+
Delta,
24+
Gamma,
2125
Parent,
2226
ParentToChildAssociation,
2327
Post,
@@ -27,13 +31,17 @@
2731
UserBio,
2832
)
2933
from tests.schemas import (
34+
AlphaSchema,
35+
BetaSchema,
3036
ChildInSchema,
3137
ChildPatchSchema,
3238
ChildSchema,
3339
ComputerInSchema,
3440
ComputerPatchSchema,
3541
ComputerSchema,
3642
CustomUUIDItemSchema,
43+
DeltaSchema,
44+
GammaSchema,
3745
ParentPatchSchema,
3846
ParentSchema,
3947
ParentToChildAssociationSchema,
@@ -249,6 +257,37 @@ def build_app_custom(
249257
return app
250258

251259

260+
def build_alphabet_app() -> FastAPI:
261+
return build_custom_app_by_schemas(
262+
[
263+
ResourceInfoDTO(
264+
path="/alpha",
265+
resource_type="alpha",
266+
model=Alpha,
267+
schema_=AlphaSchema,
268+
),
269+
ResourceInfoDTO(
270+
path="/beta",
271+
resource_type="beta",
272+
model=Beta,
273+
schema_=BetaSchema,
274+
),
275+
ResourceInfoDTO(
276+
path="/gamma",
277+
resource_type="gamma",
278+
model=Gamma,
279+
schema_=GammaSchema,
280+
),
281+
ResourceInfoDTO(
282+
path="/delta",
283+
resource_type="delta",
284+
model=Delta,
285+
schema_=DeltaSchema,
286+
),
287+
],
288+
)
289+
290+
252291
class ResourceInfoDTO(BaseModel):
253292
path: str
254293
resource_type: str

tests/test_api/test_api_sqla_with_includes.py

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from fastapi_jsonapi.views.view_base import ViewBase
2121
from tests.common import is_postgres_tests
22-
from tests.fixtures.app import ResourceInfoDTO, build_app_custom, build_custom_app_by_schemas
22+
from tests.fixtures.app import build_alphabet_app, build_app_custom
2323
from tests.fixtures.entities import build_workplace, create_user
2424
from tests.misc.utils import fake
2525
from tests.models import (
@@ -38,12 +38,8 @@
3838
Workplace,
3939
)
4040
from tests.schemas import (
41-
AlphaSchema,
42-
BetaSchema,
4341
CustomUserAttributesSchema,
4442
CustomUUIDItemAttributesSchema,
45-
DeltaSchema,
46-
GammaSchema,
4743
PostAttributesBaseSchema,
4844
PostCommentAttributesBaseSchema,
4945
SelfRelationshipSchema,
@@ -2752,70 +2748,27 @@ async def test_join_by_relationships_for_one_model_by_different_join_chains(
27522748
self,
27532749
async_session: AsyncSession,
27542750
):
2755-
app = build_custom_app_by_schemas(
2756-
[
2757-
ResourceInfoDTO(
2758-
path="/alpha",
2759-
resource_type="alpha",
2760-
model=Alpha,
2761-
schema_=AlphaSchema,
2762-
),
2763-
ResourceInfoDTO(
2764-
path="/beta",
2765-
resource_type="beta",
2766-
model=Beta,
2767-
schema_=BetaSchema,
2768-
),
2769-
ResourceInfoDTO(
2770-
path="/gamma",
2771-
resource_type="gamma",
2772-
model=Gamma,
2773-
schema_=GammaSchema,
2774-
),
2775-
ResourceInfoDTO(
2776-
path="/delta",
2777-
resource_type="delta",
2778-
model=Delta,
2779-
schema_=DeltaSchema,
2780-
),
2781-
],
2782-
)
2783-
2784-
# acc_1 = Account(name="account-1")
2785-
# role_1 = Role(delta=acc_1)
2786-
# user_1 = User()
2751+
app = build_alphabet_app()
27872752

27882753
delta_1 = Delta(name="delta_1")
2789-
beta_1, beta_2 = Beta(), Beta()
2754+
delta_1.betas = [beta_1 := Beta()]
27902755

27912756
gamma_1 = Gamma(delta=delta_1)
27922757
gamma_1.betas = [beta_1]
2793-
gamma_2 = Gamma(delta=delta_1)
2794-
gamma_2.betas = [beta_2]
2795-
delta_1.betas = [beta_1, beta_2]
27962758

27972759
delta_2 = Delta(name="delta_2")
2798-
beta_3 = Beta()
2799-
beta_4 = Beta()
2800-
gamma_3 = Gamma(delta=delta_2)
2801-
gamma_3.betas = [beta_3]
2802-
gamma_4 = Gamma(delta=delta_2)
2803-
gamma_4.betas = [beta_4]
2804-
delta_2.betas = [beta_3, beta_4]
2760+
gamma_2 = Gamma(delta=delta_2)
28052761

2806-
alpha_1 = Alpha(beta=beta_1, gamma=gamma_3)
2807-
alpha_2 = Alpha(beta=beta_3, gamma=gamma_3)
2762+
alpha_1 = Alpha(beta=beta_1, gamma=gamma_2)
28082763

28092764
async_session.add_all(
28102765
[
28112766
delta_1,
28122767
delta_2,
2768+
beta_1,
28132769
gamma_1,
28142770
gamma_2,
2815-
gamma_3,
2816-
gamma_4,
28172771
alpha_1,
2818-
alpha_2,
28192772
],
28202773
)
28212774
await async_session.commit()
@@ -2824,8 +2777,16 @@ async def test_join_by_relationships_for_one_model_by_different_join_chains(
28242777
params = {
28252778
"filter": json.dumps(
28262779
[
2827-
{"name": "beta.gammas.delta.name", "op": "ilike", "val": delta_1.name},
2828-
{"name": "gamma.delta.name", "op": "ilike", "val": delta_2.name},
2780+
{
2781+
"name": "beta.gammas.delta.name",
2782+
"op": "eq",
2783+
"val": delta_1.name,
2784+
},
2785+
{
2786+
"name": "gamma.delta.name",
2787+
"op": "eq",
2788+
"val": delta_2.name,
2789+
},
28292790
],
28302791
),
28312792
}

0 commit comments

Comments
 (0)