Skip to content

Commit 00a907b

Browse files
authored
Updated stein tests in include new binding names (#1078)
* Update stein tests for new binding names * Fixed flake8 errors
1 parent c906184 commit 00a907b

File tree

9 files changed

+189
-187
lines changed

9 files changed

+189
-187
lines changed

azure_functions_worker/_thirdparty/typing_inspect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ def _gorg(cls):
4545

4646

4747
def is_generic_type(tp):
48-
"""Test if the given type is a generic type. This includes Generic itself, but
49-
excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
48+
"""Test if the given type is a generic type. This includes Generic itself,
49+
but excludes special typing constructs such as Union, Tuple, Callable,
50+
ClassVar.
5051
Examples::
5152
5253
is_generic_type(int) == False
@@ -333,7 +334,8 @@ def get_args(tp, evaluate=None):
333334

334335

335336
def get_generic_type(obj):
336-
"""Get the generic type of an object if possible, or runtime class otherwise.
337+
"""Get the generic type of an object if possible, or runtime class
338+
otherwise.
337339
Examples::
338340
339341
class Node(Generic[T]):

tests/endtoend/blob_functions/blob_functions_stein/function_app.py

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
@app.blob_trigger(arg_name="file",
1616
path="python-worker-tests/test-blob-trigger.txt",
1717
connection="AzureWebJobsStorage")
18-
@app.write_blob(arg_name="$return",
19-
path="python-worker-tests/test-blob-triggered.txt",
20-
connection="AzureWebJobsStorage")
18+
@app.blob_output(arg_name="$return",
19+
path="python-worker-tests/test-blob-triggered.txt",
20+
connection="AzureWebJobsStorage")
2121
def blob_trigger(file: func.InputStream) -> str:
2222
return json.dumps({
2323
'name': file.name,
@@ -28,21 +28,21 @@ def blob_trigger(file: func.InputStream) -> str:
2828

2929
@app.function_name(name="get_blob_as_bytes")
3030
@app.route(route="get_blob_as_bytes")
31-
@app.read_blob(arg_name="file",
32-
path="python-worker-tests/test-bytes.txt",
33-
data_type="BINARY",
34-
connection="AzureWebJobsStorage")
31+
@app.blob_input(arg_name="file",
32+
path="python-worker-tests/test-bytes.txt",
33+
data_type="BINARY",
34+
connection="AzureWebJobsStorage")
3535
def get_blob_as_bytes(req: func.HttpRequest, file: bytes) -> str:
3636
assert isinstance(file, bytes)
3737
return file.decode('utf-8')
3838

3939

4040
@app.function_name(name="get_blob_as_bytes_return_http_response")
4141
@app.route(route="get_blob_as_bytes_return_http_response")
42-
@app.read_blob(arg_name="file",
43-
path="python-worker-tests/shmem-test-bytes.txt",
44-
data_type="BINARY",
45-
connection="AzureWebJobsStorage")
42+
@app.blob_input(arg_name="file",
43+
path="python-worker-tests/shmem-test-bytes.txt",
44+
data_type="BINARY",
45+
connection="AzureWebJobsStorage")
4646
def get_blob_as_bytes_return_http_response(req: func.HttpRequest, file: bytes) \
4747
-> func.HttpResponse:
4848
"""
@@ -70,10 +70,10 @@ def get_blob_as_bytes_return_http_response(req: func.HttpRequest, file: bytes) \
7070

7171
@app.function_name(name="get_blob_as_bytes_stream_return_http_response")
7272
@app.route(route="get_blob_as_bytes_stream_return_http_response")
73-
@app.read_blob(arg_name="file",
74-
path="python-worker-tests/shmem-test-bytes.txt",
75-
data_type="BINARY",
76-
connection="AzureWebJobsStorage")
73+
@app.blob_input(arg_name="file",
74+
path="python-worker-tests/shmem-test-bytes.txt",
75+
data_type="BINARY",
76+
connection="AzureWebJobsStorage")
7777
def get_blob_as_bytes_stream_return_http_response(req: func.HttpRequest,
7878
file: func.InputStream) \
7979
-> func.HttpResponse:
@@ -102,21 +102,21 @@ def get_blob_as_bytes_stream_return_http_response(req: func.HttpRequest,
102102

103103
@app.function_name(name="get_blob_as_str")
104104
@app.route(route="get_blob_as_str")
105-
@app.read_blob(arg_name="file",
106-
path="python-worker-tests/test-str.txt",
107-
data_type="STRING",
108-
connection="AzureWebJobsStorage")
105+
@app.blob_input(arg_name="file",
106+
path="python-worker-tests/test-str.txt",
107+
data_type="STRING",
108+
connection="AzureWebJobsStorage")
109109
def get_blob_as_str(req: func.HttpRequest, file: str) -> str:
110110
assert isinstance(file, str)
111111
return file
112112

113113

114114
@app.function_name(name="get_blob_as_str_return_http_response")
115115
@app.route(route="get_blob_as_str_return_http_response")
116-
@app.read_blob(arg_name="file",
117-
path="python-worker-tests/shmem-test-bytes.txt",
118-
data_type="STRING",
119-
connection="AzureWebJobsStorage")
116+
@app.blob_input(arg_name="file",
117+
path="python-worker-tests/shmem-test-bytes.txt",
118+
data_type="STRING",
119+
connection="AzureWebJobsStorage")
120120
def get_blob_as_str_return_http_response(req: func.HttpRequest,
121121
file: str) -> func.HttpResponse:
122122
"""
@@ -145,54 +145,54 @@ def get_blob_as_str_return_http_response(req: func.HttpRequest,
145145

146146
@app.function_name(name="get_blob_bytes")
147147
@app.route(route="get_blob_bytes")
148-
@app.read_blob(arg_name="file",
149-
path="python-worker-tests/test-bytes.txt",
150-
connection="AzureWebJobsStorage")
148+
@app.blob_input(arg_name="file",
149+
path="python-worker-tests/test-bytes.txt",
150+
connection="AzureWebJobsStorage")
151151
def get_blob_bytes(req: func.HttpRequest, file: func.InputStream) -> str:
152152
return file.read().decode('utf-8')
153153

154154

155155
@app.function_name(name="get_blob_filelike")
156156
@app.route(route="get_blob_filelike")
157-
@app.read_blob(arg_name="file",
158-
path="python-worker-tests/test-filelike.txt",
159-
connection="AzureWebJobsStorage")
157+
@app.blob_input(arg_name="file",
158+
path="python-worker-tests/test-filelike.txt",
159+
connection="AzureWebJobsStorage")
160160
def get_blob_filelike(req: func.HttpRequest, file: func.InputStream) -> str:
161161
return file.read().decode('utf-8')
162162

163163

164164
@app.function_name(name="get_blob_return")
165165
@app.route(route="get_blob_return")
166-
@app.read_blob(arg_name="file",
167-
path="python-worker-tests/test-return.txt",
168-
connection="AzureWebJobsStorage")
166+
@app.blob_input(arg_name="file",
167+
path="python-worker-tests/test-return.txt",
168+
connection="AzureWebJobsStorage")
169169
def get_blob_return(req: func.HttpRequest, file: func.InputStream) -> str:
170170
return file.read().decode('utf-8')
171171

172172

173173
@app.function_name(name="get_blob_str")
174174
@app.route(route="get_blob_str")
175-
@app.read_blob(arg_name="file",
176-
path="python-worker-tests/test-str.txt",
177-
connection="AzureWebJobsStorage")
175+
@app.blob_input(arg_name="file",
176+
path="python-worker-tests/test-str.txt",
177+
connection="AzureWebJobsStorage")
178178
def get_blob_str(req: func.HttpRequest, file: func.InputStream) -> str:
179179
return file.read().decode('utf-8')
180180

181181

182182
@app.function_name(name="get_blob_triggered")
183-
@app.read_blob(arg_name="file",
184-
path="python-worker-tests/test-blob-triggered.txt",
185-
connection="AzureWebJobsStorage")
183+
@app.blob_input(arg_name="file",
184+
path="python-worker-tests/test-blob-triggered.txt",
185+
connection="AzureWebJobsStorage")
186186
@app.route(route="get_blob_triggered")
187187
def get_blob_triggered(req: func.HttpRequest, file: func.InputStream) -> str:
188188
return file.read().decode('utf-8')
189189

190190

191191
@app.function_name(name="put_blob_as_bytes_return_http_response")
192-
@app.write_blob(arg_name="file",
193-
path="python-worker-tests/shmem-test-bytes-out.txt",
194-
data_type="BINARY",
195-
connection="AzureWebJobsStorage")
192+
@app.blob_output(arg_name="file",
193+
path="python-worker-tests/shmem-test-bytes-out.txt",
194+
data_type="BINARY",
195+
connection="AzureWebJobsStorage")
196196
@app.route(route="put_blob_as_bytes_return_http_response")
197197
def put_blob_as_bytes_return_http_response(req: func.HttpRequest,
198198
file: func.Out[
@@ -231,13 +231,13 @@ def put_blob_as_bytes_return_http_response(req: func.HttpRequest,
231231

232232

233233
@app.function_name(name="put_blob_as_str_return_http_response")
234-
@app.write_blob(arg_name="file",
235-
path="python-worker-tests/shmem-test-str-out.txt",
236-
data_type="STRING",
237-
connection="AzureWebJobsStorage")
234+
@app.blob_output(arg_name="file",
235+
path="python-worker-tests/shmem-test-str-out.txt",
236+
data_type="STRING",
237+
connection="AzureWebJobsStorage")
238238
@app.route(route="put_blob_as_str_return_http_response")
239239
def put_blob_as_str_return_http_response(req: func.HttpRequest, file: func.Out[
240-
str]) -> func.HttpResponse:
240+
str]) -> func.HttpResponse:
241241
"""
242242
Write a blob (string) and respond back (in HTTP response) with the number of
243243
characters written and the MD5 digest of the utf-8 encoded content.
@@ -269,19 +269,19 @@ def put_blob_as_str_return_http_response(req: func.HttpRequest, file: func.Out[
269269

270270

271271
@app.function_name(name="put_blob_bytes")
272-
@app.write_blob(arg_name="file",
273-
path="python-worker-tests/test-bytes.txt",
274-
connection="AzureWebJobsStorage")
272+
@app.blob_output(arg_name="file",
273+
path="python-worker-tests/test-bytes.txt",
274+
connection="AzureWebJobsStorage")
275275
@app.route(route="put_blob_bytes")
276276
def put_blob_bytes(req: func.HttpRequest, file: func.Out[bytes]) -> str:
277277
file.set(req.get_body())
278278
return 'OK'
279279

280280

281281
@app.function_name(name="put_blob_filelike")
282-
@app.write_blob(arg_name="file",
283-
path="python-worker-tests/test-filelike.txt",
284-
connection="AzureWebJobsStorage")
282+
@app.blob_output(arg_name="file",
283+
path="python-worker-tests/test-filelike.txt",
284+
connection="AzureWebJobsStorage")
285285
@app.route(route="put_blob_filelike")
286286
def put_blob_filelike(req: func.HttpRequest,
287287
file: func.Out[io.StringIO]) -> str:
@@ -290,29 +290,29 @@ def put_blob_filelike(req: func.HttpRequest,
290290

291291

292292
@app.function_name(name="put_blob_return")
293-
@app.write_blob(arg_name="$return",
294-
path="python-worker-tests/test-return.txt",
295-
connection="AzureWebJobsStorage")
293+
@app.blob_output(arg_name="$return",
294+
path="python-worker-tests/test-return.txt",
295+
connection="AzureWebJobsStorage")
296296
@app.route(route="put_blob_return", binding_arg_name="resp")
297297
def put_blob_return(req: func.HttpRequest,
298298
resp: func.Out[func.HttpResponse]) -> str:
299299
return 'FROM RETURN'
300300

301301

302302
@app.function_name(name="put_blob_str")
303-
@app.write_blob(arg_name="file",
304-
path="python-worker-tests/test-str.txt",
305-
connection="AzureWebJobsStorage")
303+
@app.blob_output(arg_name="file",
304+
path="python-worker-tests/test-str.txt",
305+
connection="AzureWebJobsStorage")
306306
@app.route(route="put_blob_str")
307307
def put_blob_str(req: func.HttpRequest, file: func.Out[str]) -> str:
308308
file.set(req.get_body())
309309
return 'OK'
310310

311311

312312
@app.function_name(name="put_blob_trigger")
313-
@app.write_blob(arg_name="file",
314-
path="python-worker-tests/test-blob-trigger.txt",
315-
connection="AzureWebJobsStorage")
313+
@app.blob_output(arg_name="file",
314+
path="python-worker-tests/test-blob-trigger.txt",
315+
connection="AzureWebJobsStorage")
316316
@app.route(route="put_blob_trigger")
317317
def put_blob_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:
318318
file.set(req.get_body())
@@ -326,22 +326,22 @@ def _generate_content_and_digest(content_size):
326326

327327

328328
@app.function_name(name="put_get_multiple_blobs_as_bytes_return_http_response")
329-
@app.read_blob(arg_name="inputfile1",
330-
data_type="BINARY",
331-
path="python-worker-tests/shmem-test-bytes-1.txt",
332-
connection="AzureWebJobsStorage")
333-
@app.read_blob(arg_name="inputfile2",
334-
data_type="BINARY",
335-
path="python-worker-tests/shmem-test-bytes-2.txt",
336-
connection="AzureWebJobsStorage")
337-
@app.write_blob(arg_name="outputfile1",
338-
path="python-worker-tests/shmem-test-bytes-out-1.txt",
329+
@app.blob_input(arg_name="inputfile1",
339330
data_type="BINARY",
331+
path="python-worker-tests/shmem-test-bytes-1.txt",
340332
connection="AzureWebJobsStorage")
341-
@app.write_blob(arg_name="outputfile2",
342-
path="python-worker-tests/shmem-test-bytes-out-2.txt",
333+
@app.blob_input(arg_name="inputfile2",
343334
data_type="BINARY",
335+
path="python-worker-tests/shmem-test-bytes-2.txt",
344336
connection="AzureWebJobsStorage")
337+
@app.blob_output(arg_name="outputfile1",
338+
path="python-worker-tests/shmem-test-bytes-out-1.txt",
339+
data_type="BINARY",
340+
connection="AzureWebJobsStorage")
341+
@app.blob_output(arg_name="outputfile2",
342+
path="python-worker-tests/shmem-test-bytes-out-2.txt",
343+
data_type="BINARY",
344+
connection="AzureWebJobsStorage")
345345
@app.route(route="put_get_multiple_blobs_as_bytes_return_http_response")
346346
def put_get_multiple_blobs_as_bytes_return_http_response(
347347
req: func.HttpRequest,

tests/endtoend/cosmosdb_functions/cosmosdb_functions_stein/function_app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@app.route()
9-
@app.read_cosmos_db_documents(
9+
@app.cosmos_db_input(
1010
arg_name="docs", database_name="test",
1111
collection_name="items",
1212
id="cosmosdb-input-test",
@@ -21,22 +21,22 @@ def cosmosdb_input(req: func.HttpRequest, docs: func.DocumentList) -> str:
2121
lease_collection_name="leases",
2222
connection_string_setting="AzureWebJobsCosmosDBConnectionString",
2323
create_lease_collection_if_not_exists=True)
24-
@app.write_blob(arg_name="$return", connection="AzureWebJobsStorage",
25-
path="python-worker-tests/test-cosmosdb-triggered.txt")
24+
@app.blob_output(arg_name="$return", connection="AzureWebJobsStorage",
25+
path="python-worker-tests/test-cosmosdb-triggered.txt")
2626
def cosmosdb_trigger(docs: func.DocumentList) -> str:
2727
return docs[0].to_json()
2828

2929

3030
@app.route()
31-
@app.read_blob(arg_name="file", connection="AzureWebJobsStorage",
32-
path="python-worker-tests/test-cosmosdb-triggered.txt")
31+
@app.blob_input(arg_name="file", connection="AzureWebJobsStorage",
32+
path="python-worker-tests/test-cosmosdb-triggered.txt")
3333
def get_cosmosdb_triggered(req: func.HttpRequest,
3434
file: func.InputStream) -> str:
3535
return file.read().decode('utf-8')
3636

3737

3838
@app.route()
39-
@app.write_cosmos_db_documents(
39+
@app.cosmos_db_output(
4040
arg_name="doc", database_name="test",
4141
collection_name="items",
4242
create_if_not_exists=True,

0 commit comments

Comments
 (0)