1- import json
21from typing import Iterator , List , Union
32
43import pytest
@@ -99,25 +98,21 @@ def delete_collection(self, collection_id: str, **kwargs):
9998
10099
101100def test_create_item (client : TestClient , item : Item ) -> None :
102- response = client .post ("/collections/a-collection/items" , content = json . dumps ( item ) )
101+ response = client .post ("/collections/a-collection/items" , json = item )
103102 assert response .is_success , response .text
104103 assert response .json ()["type" ] == "Feature"
105104
106105
107106def test_create_item_collection (
108107 client : TestClient , item_collection : ItemCollection
109108) -> None :
110- response = client .post (
111- "/collections/a-collection/items" , content = json .dumps (item_collection )
112- )
109+ response = client .post ("/collections/a-collection/items" , json = item_collection )
113110 assert response .is_success , response .text
114111 assert response .json ()["type" ] == "FeatureCollection"
115112
116113
117114def test_update_item (client : TestClient , item : Item ) -> None :
118- response = client .put (
119- "/collections/a-collection/items/an-item" , content = json .dumps (item )
120- )
115+ response = client .put ("/collections/a-collection/items/an-item" , json = item )
121116 assert response .is_success , response .text
122117 assert response .json ()["path_collection_id" ] == "a-collection"
123118 assert response .json ()["path_item_id" ] == "an-item"
@@ -127,7 +122,7 @@ def test_update_item(client: TestClient, item: Item) -> None:
127122def test_patch_operation_item (client : TestClient ) -> None :
128123 response = client .patch (
129124 "/collections/a-collection/items/an-item" ,
130- content = ' [{"op": "add", "path": "/properties/foo", "value": "bar"}]' ,
125+ json = [{"op" : "add" , "path" : "/properties/foo" , "value" : "bar" }],
131126 )
132127 assert response .is_success , response .text
133128 assert response .json ()["path_collection_id" ] == "a-collection"
@@ -140,7 +135,7 @@ def test_patch_operation_item(client: TestClient) -> None:
140135def test_patch_merge_item (client : TestClient ) -> None :
141136 response = client .patch (
142137 "/collections/a-collection/items/an-item" ,
143- content = json . dumps ( {"properties" : {"hello" : "world" , "foo" : None }}) ,
138+ json = {"properties" : {"hello" : "world" , "foo" : None }},
144139 )
145140 assert response .is_success , response .text
146141 assert response .json ()["path_collection_id" ] == "a-collection"
@@ -159,13 +154,13 @@ def test_delete_item(client: TestClient) -> None:
159154
160155
161156def test_create_collection (client : TestClient , collection : Collection ) -> None :
162- response = client .post ("/collections" , content = json . dumps ( collection ) )
157+ response = client .post ("/collections" , json = collection )
163158 assert response .is_success , response .text
164159 assert response .json ()["type" ] == "Collection"
165160
166161
167162def test_update_collection (client : TestClient , collection : Collection ) -> None :
168- response = client .put ("/collections/a-collection" , content = json . dumps ( collection ) )
163+ response = client .put ("/collections/a-collection" , json = collection )
169164 assert response .is_success , response .text
170165 assert response .json ()["path_collection_id" ] == "a-collection"
171166 assert response .json ()["type" ] == "Collection"
@@ -174,7 +169,7 @@ def test_update_collection(client: TestClient, collection: Collection) -> None:
174169def test_patch_operation_collection (client : TestClient ) -> None :
175170 response = client .patch (
176171 "/collections/a-collection" ,
177- content = ' [{"op": "add", "path": "/properties/foo", "value": "bar"}]' ,
172+ json = [{"op" : "add" , "path" : "/properties/foo" , "value" : "bar" }],
178173 )
179174 assert response .is_success , response .text
180175 assert response .json ()["path_collection_id" ] == "a-collection"
@@ -186,7 +181,7 @@ def test_patch_operation_collection(client: TestClient) -> None:
186181def test_patch_merge_collection (client : TestClient ) -> None :
187182 response = client .patch (
188183 "/collections/a-collection" ,
189- content = json . dumps ( {"summaries" : {"hello" : "world" , "foo" : None }}) ,
184+ json = {"summaries" : {"hello" : "world" , "foo" : None }},
190185 )
191186 assert response .is_success , response .text
192187 assert response .json ()["path_collection_id" ] == "a-collection"
0 commit comments