Skip to content

Commit 6272e70

Browse files
committed
fix: ObjectResponse with fields not compatible with Tile38 v1.30.0
1 parent 3578319 commit 6272e70

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

pyle38/responses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Object(BaseModel, Generic[T]):
3737
object: T
3838
id: Union[str, int]
3939
distance: Optional[float] = None
40-
fields: Optional[List[int]] = None
40+
fields: Optional[List[Any]] = None
4141

4242

4343
class ObjectResponse(JSONResponse, BaseModel, Generic[T]):

tests/test_command_intersects.py

+30
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,36 @@ async def test_command_intersects_compile(tile38):
8888
expected = {"id": id, "object": feature}
8989

9090

91+
@pytest.mark.asyncio
92+
async def test_command_intersects_with_fields(tile38):
93+
# field type str
94+
name = "Tom"
95+
# field type float
96+
weight = 111.1
97+
# field type int
98+
height = 190
99+
# field type dict
100+
info = {"height": height, "weight": weight, "name": name}
101+
102+
response = (
103+
await tile38.set(key, id)
104+
.fields({"info": info, "height": height, "weight": weight, "name": name})
105+
.object(feature)
106+
.exec()
107+
)
108+
assert response.ok
109+
110+
response = (
111+
await tile38.intersects(key).bounds(52.24, 13.36, 52.256, 13.379).asObjects()
112+
)
113+
assert response.ok
114+
assert response.objects[0].dict() == {
115+
**expected,
116+
# in lexical order
117+
"fields": [height, info, name, weight],
118+
}
119+
120+
91121
@pytest.mark.asyncio
92122
async def test_command_intersects_circle(tile38):
93123
response = await tile38.set(key, id).object(feature).exec()

0 commit comments

Comments
 (0)