Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 21, 2024
1 parent 928baff commit f1acaca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
14 changes: 8 additions & 6 deletions tests/mongoengine/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_api(self, client):
data = response.json()
assert data["total"] == 5
assert len(data["items"]) == 2
assert ["OPPOF19", "IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["OPPOF19", "IPhone X"]
# Find by pks
response = client.get(
"/admin/api/product",
Expand All @@ -150,7 +150,7 @@ def test_api_fulltext(self, client):
)
data = response.json()
assert data["total"] == 2
assert ["IPhone 9", "IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["IPhone 9", "IPhone X"]

def test_api_query1(self, client):
where = (
Expand All @@ -160,8 +160,10 @@ def test_api_query1(self, client):
response = client.get(f"/admin/api/product?where={where}&order_by=price asc")
data = response.json()
assert data["total"] == 3
assert ["OPPOF19", "Huawei P30", "IPhone 9"] == [
x["title"] for x in data["items"]
assert [x["title"] for x in data["items"]] == [
"OPPOF19",
"Huawei P30",
"IPhone 9",
]

def test_api_query2(self, client):
Expand All @@ -172,13 +174,13 @@ def test_api_query2(self, client):
response = client.get(f"/admin/api/product?where={where}")
data = response.json()
assert data["total"] == 1
assert ["IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["IPhone X"]

def test_api_query3(self, client):
response = client.get("/admin/api/product?order_by=price desc&limit=2")
data = response.json()
assert data["total"] == 5
assert ["Samsung Universe 9", "IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["Samsung Universe 9", "IPhone X"]

def test_detail(self, client):
id = Product.objects(title="IPhone 9").get().id
Expand Down
4 changes: 2 additions & 2 deletions tests/odmantic/test_async_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def test_api(client: AsyncClient):
data = response.json()
assert data["total"] == 3
assert len(data["items"]) == 2
assert ["Sheldon Cole", "Terry Medhurst"] == [x["name"] for x in data["items"]]
assert [x["name"] for x in data["items"]] == ["Sheldon Cole", "Terry Medhurst"]
# Find by pks
response = await client.get(
"/admin/api/user", params={"pks": [x["id"] for x in data["items"]]}
Expand All @@ -128,7 +128,7 @@ async def test_full_text_search(client: AsyncClient):
assert response.status_code == 200
data = response.json()
assert data["total"] == 2
assert ["Hills Terrill", "Terry Medhurst"] == [x["name"] for x in data["items"]]
assert [x["name"] for x in data["items"]] == ["Hills Terrill", "Terry Medhurst"]


async def test_deep_search(client: AsyncClient, aio_engine: AIOEngine):
Expand Down
2 changes: 1 addition & 1 deletion tests/odmantic/test_sync_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def test_api(client: AsyncClient):
data = response.json()
assert data["total"] == 3
assert len(data["items"]) == 2
assert ["Jim Rohn", "Albert Einstein"] == [x["name"] for x in data["items"]]
assert [x["name"] for x in data["items"]] == ["Jim Rohn", "Albert Einstein"]
# Find by pks
response = await client.get(
"/admin/api/author", params={"pks": [x["id"] for x in data["items"]]}
Expand Down
14 changes: 7 additions & 7 deletions tests/sqla/test_sync_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def test_api(client: AsyncClient):
data = response.json()
assert data["total"] == 5
assert len(data["items"]) == 2
assert ["OPPOF19", "IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["OPPOF19", "IPhone X"]
# Find by pks
response = await client.get(
"/admin/api/product",
Expand All @@ -196,7 +196,7 @@ async def test_api_fulltext(client: AsyncClient):
)
data = response.json()
assert data["total"] == 2
assert ["IPhone 9", "IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["IPhone 9", "IPhone X"]


async def test_api_query1(client: AsyncClient):
Expand All @@ -207,7 +207,7 @@ async def test_api_query1(client: AsyncClient):
response = await client.get(f"/admin/api/product?where={where}&order_by=price asc")
data = response.json()
assert data["total"] == 3
assert ["OPPOF19", "Huawei P30", "IPhone 9"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["OPPOF19", "Huawei P30", "IPhone 9"]


async def test_api_query2(client: AsyncClient):
Expand All @@ -218,7 +218,7 @@ async def test_api_query2(client: AsyncClient):
response = await client.get(f"/admin/api/product?where={where}")
data = response.json()
assert data["total"] == 1
assert ["IPhone X"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["IPhone X"]


async def test_api_query3(client: AsyncClient):
Expand All @@ -229,7 +229,7 @@ async def test_api_query3(client: AsyncClient):
response = await client.get(f"/admin/api/product?where={where}&order_by=price asc")
data = response.json()
assert data["total"] == 2
assert ["OPPOF19", "Huawei P30"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["OPPOF19", "Huawei P30"]


async def test_api_query4(client: AsyncClient):
Expand Down Expand Up @@ -608,7 +608,7 @@ async def test_sortable_field_mapping_1(client: AsyncClient, session: Session):
data = response.json()
assert data["total"] == 5
assert len(data["items"]) == 2
assert ["Huawei P30", "OPPOF19"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["Huawei P30", "OPPOF19"]


@pytest.mark.skipif(
Expand All @@ -620,4 +620,4 @@ async def test_sortable_field_mapping_2(client: AsyncClient, session: Session):
data = response.json()
assert data["total"] == 5
assert len(data["items"]) == 2
assert ["OPPOF19", "Huawei P30"] == [x["title"] for x in data["items"]]
assert [x["title"] for x in data["items"]] == ["OPPOF19", "Huawei P30"]
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class MyModelView(DummyModelView):
# Test Api
response = client.get("/admin/api/my-model?pks=1")
assert response.status_code == 200
assert [1] == [x["id"] for x in response.json()["items"]]
assert [x["id"] for x in response.json()["items"]] == [1]

# Test edit page load
response = client.get("/admin/my-model/edit/1")
Expand Down

0 comments on commit f1acaca

Please sign in to comment.