From 814c157baee721536cc4e4b52db0c84821b7aa55 Mon Sep 17 00:00:00 2001 From: Heena Gupta Date: Mon, 16 Dec 2024 23:48:06 +0530 Subject: [PATCH 01/11] mysql decorators --- azure/functions/decorators/constants.py | 2 + azure/functions/decorators/function_app.py | 158 ++++++++++++++++++ azure/functions/decorators/mysql.py | 61 +++++++ docs/ProgModelSpec.pyi | 110 +++++++++++++ tests/decorators/test_decorators.py | 181 ++++++++++++++++++++- tests/decorators/test_mysql.py | 60 +++++++ 6 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 azure/functions/decorators/mysql.py create mode 100644 tests/decorators/test_mysql.py diff --git a/azure/functions/decorators/constants.py b/azure/functions/decorators/constants.py index 8d699b99..f1e45257 100644 --- a/azure/functions/decorators/constants.py +++ b/azure/functions/decorators/constants.py @@ -43,3 +43,5 @@ ASSISTANT_CREATE = "assistantCreate" ASSISTANT_POST = "assistantPost" SEMANTIC_SEARCH = "semanticSearch" +MYSQL = "mysql" +MYSQL_TRIGGER = "mysqlTrigger" diff --git a/azure/functions/decorators/function_app.py b/azure/functions/decorators/function_app.py index 9c0b99f6..82186c06 100644 --- a/azure/functions/decorators/function_app.py +++ b/azure/functions/decorators/function_app.py @@ -47,6 +47,7 @@ from .warmup import WarmUpTrigger from .._http_asgi import AsgiMiddleware from .._http_wsgi import WsgiMiddleware, Context +from azure.functions.decorators.mysql import MySqlInput, MySqlOutput, MySqlTrigger class Function(object): @@ -1442,6 +1443,59 @@ def decorator(): return decorator() return wrap + + def mysql_trigger(self, + arg_name: str, + table_name: str, + connection_string_setting: str, + leases_table_name: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_trigger decorator adds :class:`MySqlTrigger` + to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlTrigger in the function.json which + enables function to be triggered when there are changes in the MySql + table. + All optional fields will be given default value by function host when + they are parsed by function host. + Ref: https://aka.ms/mysqlbindings + :param arg_name: The name of the variable that represents a + :class:`MySqlRowList` object in the function code + :param table_name: The name of the table monitored by the trigger + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param leases_table_name: The name of the table used to store + leases. If not specified, the leases table name will be + Leases_{FunctionId}_{TableId}. + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + :return: Decorator function. + """ + + @self._configure_function_builder + def wrap(fb): + def decorator(): + fb.add_trigger( + trigger=MySqlTrigger( + name=arg_name, + table_name=table_name, + connection_string_setting=connection_string_setting, + leases_table_name=leases_table_name, + data_type=parse_singular_param_to_enum(data_type, + DataType), + **kwargs)) + return fb + + return decorator() + + return wrap + def generic_trigger(self, arg_name: str, @@ -3551,6 +3605,110 @@ def decorator(): return decorator() return wrap + + def mysql_input(self, + arg_name: str, + command_text: str, + connection_string_setting: str, + command_type: Optional[str] = 'Text', + parameters: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_input decorator adds + :class:`MySqlInput` to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlInput in the function.json which + enables the function to read from a MySql database. + All optional fields will be given default value by function host when + they are parsed by function host. + Ref: https://aka.ms/mysqlbindings + :param arg_name: The name of the variable that represents a + :class:`MySqlRowList` input object in function code + :param command_text: The Transact-SQL query command or name of the + stored procedure executed by the binding + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param command_type: A CommandType value, which is Text for a query + and StoredProcedure for a stored procedure + :param parameters: Zero or more parameter values passed to the + command during execution as a single string. Must follow the format + @param1=param1,@param2=param2 + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + :return: Decorator function. + """ + + @self._configure_function_builder + def wrap(fb): + def decorator(): + fb.add_binding( + binding=MySqlInput( + name=arg_name, + command_text=command_text, + connection_string_setting=connection_string_setting, + command_type=command_type, + parameters=parameters, + data_type=parse_singular_param_to_enum(data_type, + DataType), + **kwargs)) + return fb + + return decorator() + + return wrap + + def mysql_output(self, + arg_name: str, + command_text: str, + connection_string_setting: str, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_output decorator adds + :class:`MySqlOutput` to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlOutput in the function.json which + enables the function to write to a MySql database. + All optional fields will be given default value by function host when + they are parsed by function host. + Ref: https://aka.ms/mysqlbindings + :param arg_name: The name of the variable that represents + MySql output object in function code + :param command_text: The Transact-SQL query command or name of the + stored procedure executed by the binding + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + :return: Decorator function. + """ + + @self._configure_function_builder + def wrap(fb): + def decorator(): + fb.add_binding( + binding=MySqlOutput( + name=arg_name, + command_text=command_text, + connection_string_setting=connection_string_setting, + data_type=parse_singular_param_to_enum(data_type, + DataType), + **kwargs)) + return fb + + return decorator() + + return wrap + class SettingsApi(DecoratorApi, ABC): diff --git a/azure/functions/decorators/mysql.py b/azure/functions/decorators/mysql.py new file mode 100644 index 00000000..2660c98b --- /dev/null +++ b/azure/functions/decorators/mysql.py @@ -0,0 +1,61 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +from typing import Optional + +from azure.functions.decorators.constants import MYSQL, MYSQL_TRIGGER +from azure.functions.decorators.core import DataType, InputBinding, \ + OutputBinding, Trigger + + +class MySqlInput(InputBinding): + @staticmethod + def get_binding_name() -> str: + return MYSQL + + def __init__(self, + name: str, + command_text: str, + connection_string_setting: str, + command_type: Optional[str] = 'Text', + parameters: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs): + self.command_text = command_text + self.connection_string_setting = connection_string_setting + self.command_type = command_type + self.parameters = parameters + super().__init__(name=name, data_type=data_type) + + +class MySqlOutput(OutputBinding): + @staticmethod + def get_binding_name() -> str: + return MYSQL + + def __init__(self, + name: str, + command_text: str, + connection_string_setting: str, + data_type: Optional[DataType] = None, + **kwargs): + self.command_text = command_text + self.connection_string_setting = connection_string_setting + super().__init__(name=name, data_type=data_type) + + +class MySqlTrigger(Trigger): + @staticmethod + def get_binding_name() -> str: + return MYSQL_TRIGGER + + def __init__(self, + name: str, + table_name: str, + connection_string_setting: str, + leases_table_name: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs): + self.table_name = table_name + self.connection_string_setting = connection_string_setting + self.leases_table_name = leases_table_name + super().__init__(name=name, data_type=data_type) \ No newline at end of file diff --git a/docs/ProgModelSpec.pyi b/docs/ProgModelSpec.pyi index dd7a5e98..b9c1d60a 100644 --- a/docs/ProgModelSpec.pyi +++ b/docs/ProgModelSpec.pyi @@ -595,6 +595,45 @@ class TriggerApi(DecoratorApi, ABC): pass + def mysql_trigger(self, + arg_name: str, + table_name: str, + connection_string_setting: str, + leases_table_name: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_trigger decorator adds :class:`MySqlTrigger` + to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlTrigger in the function.json which + enables function to be triggered when there are changes in the MySql + table. + All optional fields will be given default value by function host when + they are parsed by function host. + + Ref: https://aka.ms/mysqlbindings + + :param arg_name: The name of the variable that represents a + :class:`MySqlRowList` object in the function code + :param table_name: The name of the table monitored by the trigger + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param leases_table_name: The name of the table used to store + leases. If not specified, the leases table name will be + Leases_{FunctionId}_{TableId}. + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + + :return: Decorator function. + """ + + pass + def generic_trigger(self, arg_name: str, type: str, @@ -1112,6 +1151,77 @@ class BindingApi(DecoratorApi, ABC): pass + def mysql_input(self, + arg_name: str, + command_text: str, + connection_string_setting: str, + command_type: Optional[str] = 'Text', + parameters: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_input decorator adds + :class:`MySqlInput` to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlInput in the function.json which + enables the function to read from a MySql database. + All optional fields will be given default value by function host when + they are parsed by function host. + Ref: https://aka.ms/mysqlbindings + :param arg_name: The name of the variable that represents a + :class:`MySqlRowList` input object in function code + :param command_text: The Transact-SQL query command or name of the + stored procedure executed by the binding + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param command_type: A CommandType value, which is Text for a query + and StoredProcedure for a stored procedure + :param parameters: Zero or more parameter values passed to the + command during execution as a single string. Must follow the format + @param1=param1,@param2=param2 + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + :return: Decorator function. + """ + + pass + + def mysql_output(self, + arg_name: str, + command_text: str, + connection_string_setting: str, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: + """The mysql_output decorator adds + :class:`MySqlOutput` to the :class:`FunctionBuilder` object + for building :class:`Function` object used in worker function + indexing model. This decorator will work only with extension bundle 4.x + and above. + This is equivalent to defining MySqlOutput in the function.json which + enables the function to write to a MySql database. + All optional fields will be given default value by function host when + they are parsed by function host. + Ref: https://aka.ms/mysqlbindings + :param arg_name: The name of the variable that represents + MySql output object in function code + :param command_text: The Transact-SQL query command or name of the + stored procedure executed by the binding + :param connection_string_setting: The name of an app setting that + contains the connection string for the database against which the + query or stored procedure is being executed + :param data_type: Defines how Functions runtime should treat the + parameter value + :param kwargs: Keyword arguments for specifying additional binding + fields to include in the binding json + :return: Decorator function. + """ + + pass + def generic_input_binding(self, arg_name: str, type: str, diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index acdd5ccd..3c6fc1af 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -7,7 +7,7 @@ EVENT_HUB, EVENT_HUB_TRIGGER, COSMOS_DB, COSMOS_DB_TRIGGER, BLOB, \ BLOB_TRIGGER, EVENT_GRID_TRIGGER, EVENT_GRID, TABLE, WARMUP_TRIGGER, \ SQL, SQL_TRIGGER, ORCHESTRATION_TRIGGER, ACTIVITY_TRIGGER, \ - ENTITY_TRIGGER, DURABLE_CLIENT + ENTITY_TRIGGER, DURABLE_CLIENT, MYSQL, MYSQL_TRIGGER from azure.functions.decorators.core import BlobSource, DataType, AuthLevel, \ BindingDirection, AccessRights, Cardinality from azure.functions.decorators.function_app import FunctionApp @@ -2376,3 +2376,182 @@ def test_function_app_retry_default_args(): 'max_retry_count': '2', 'delay_interval': '4' }) + + def test_mysql_default_args(self): + app = self.func_app + + @app.mysql_trigger(arg_name="trigger", + table_name="dummy_table", + connection_string_setting="dummy_setting") + @app.mysql_input(arg_name="in", + command_text="dummy_query", + connection_string_setting="dummy_setting") + @app.mysql_output(arg_name="out", + command_text="dummy_table", + connection_string_setting="dummy_setting") + def dummy(): + pass + + func = self._get_user_function(app) + + assert_json(self, func, { + "scriptFile": "function_app.py", + "bindings": [ + { + "direction": BindingDirection.OUT, + "type": MYSQL, + "name": "out", + "commandText": "dummy_table", + "connectionStringSetting": "dummy_setting" + }, + { + "direction": BindingDirection.IN, + "type": MYSQL, + "name": "in", + "commandText": "dummy_query", + "connectionStringSetting": "dummy_setting", + "commandType": "Text" + }, + { + "direction": BindingDirection.IN, + "type": MYSQL_TRIGGER, + "name": "trigger", + "tableName": "dummy_table", + "connectionStringSetting": "dummy_setting" + } + ] + }) + + def test_mysql_full_args(self): + app = self.func_app + + @app.mysql_trigger(arg_name="trigger", + table_name="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.STRING, + dummy_field="dummy") + @app.mysql_input(arg_name="in", + command_text="dummy_query", + connection_string_setting="dummy_setting", + command_type="Text", + parameters="dummy_parameters", + data_type=DataType.STRING, + dummy_field="dummy") + @app.mysql_output(arg_name="out", + command_text="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.STRING, + dummy_field="dummy") + def dummy(): + pass + + func = self._get_user_function(app) + + assert_json(self, func, { + "scriptFile": "function_app.py", + "bindings": [ + { + "direction": BindingDirection.OUT, + 'dummyField': 'dummy', + "dataType": DataType.STRING, + "type": MYSQL, + "name": "out", + "commandText": "dummy_table", + "connectionStringSetting": "dummy_setting" + }, + { + "direction": BindingDirection.IN, + 'dummyField': 'dummy', + "dataType": DataType.STRING, + "type": MYSQL, + "name": "in", + "commandText": "dummy_query", + "connectionStringSetting": "dummy_setting", + "parameters": "dummy_parameters", + "commandType": "Text" + }, + { + "direction": BindingDirection.IN, + 'dummyField': 'dummy', + "dataType": DataType.STRING, + "type": MYSQL_TRIGGER, + "name": "trigger", + "tableName": "dummy_table", + "connectionStringSetting": "dummy_setting" + } + ] + }) + + def test_mysql_trigger(self): + app = self.func_app + + @app.mysql_trigger(arg_name="trigger", + table_name="dummy_table", + connection_string_setting="dummy_setting") + def dummy(): + pass + + func = self._get_user_function(app) + + self.assertEqual(len(func.get_bindings()), 1) + + output = func.get_bindings()[0] + self.assertEqual(output.get_dict_repr(), { + "direction": BindingDirection.IN, + "type": MYSQL_TRIGGER, + "name": "trigger", + "tableName": "dummy_table", + "connectionStringSetting": "dummy_setting" + }) + + def test_mysql_input_binding(self): + app = self.func_app + + @app.mysql_trigger(arg_name="trigger", + table_name="dummy_table", + connection_string_setting="dummy_setting") + @app.mysql_input(arg_name="in", + command_text="dummy_query", + connection_string_setting="dummy_setting") + def dummy(): + pass + + func = self._get_user_function(app) + + self.assertEqual(len(func.get_bindings()), 2) + + output = func.get_bindings()[0] + self.assertEqual(output.get_dict_repr(), { + "direction": BindingDirection.IN, + "type": MYSQL, + "name": "in", + "commandText": "dummy_query", + "connectionStringSetting": "dummy_setting", + "commandType": "Text" + }) + + def test_mysql_output_binding(self): + app = self.func_app + + @app.mysql_trigger(arg_name="trigger", + table_name="dummy_table", + connection_string_setting="dummy_setting") + @app.mysql_output(arg_name="out", + command_text="dummy_table", + connection_string_setting="dummy_setting") + def dummy(): + pass + + func = self._get_user_function(app) + + self.assertEqual(len(func.get_bindings()), 2) + + output = func.get_bindings()[0] + self.assertEqual(output.get_dict_repr(), { + "direction": BindingDirection.OUT, + "type": MYSQL, + "name": "out", + "commandText": "dummy_table", + "connectionStringSetting": "dummy_setting", + }) + diff --git a/tests/decorators/test_mysql.py b/tests/decorators/test_mysql.py new file mode 100644 index 00000000..626e1ac4 --- /dev/null +++ b/tests/decorators/test_mysql.py @@ -0,0 +1,60 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +import unittest + +from azure.functions.decorators.constants import MYSQL, MYSQL_TRIGGER +from azure.functions.decorators.core import BindingDirection, DataType +from azure.functions.decorators.mysql import MySqlInput, \ + MySqlOutput, MySqlTrigger + + +class TestMySql(unittest.TestCase): + def test_mysql_input_valid_creation(self): + input = MySqlInput(name="req", + command_text="dummy_query", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") + self.assertEqual(input.get_binding_name(), "mysql") + self.assertEqual(input.get_dict_repr(), + {"commandText": "dummy_query", + "connectionStringSetting": "dummy_setting", + "commandType": "Text", + "dataType": DataType.UNDEFINED, + "direction": BindingDirection.IN, + "dummyField": "dummy", + "name": "req", + "type": MYSQL}) + + def test_mysql_output_valid_creation(self): + output = MySqlOutput(name="req", + command_text="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") + self.assertEqual(output.get_binding_name(), "mysql") + self.assertEqual(output.get_dict_repr(), + {"commandText": "dummy_table", + "connectionStringSetting": "dummy_setting", + "dataType": DataType.UNDEFINED, + "direction": BindingDirection.OUT, + "dummyField": "dummy", + "name": "req", + "type": MYSQL}) + + def test_mysql_trigger_valid_creation(self): + trigger = MySqlTrigger(name="req", + table_name="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") + + self.assertEqual(trigger.get_binding_name(), "mysqlTrigger") + self.assertEqual(trigger.get_dict_repr(), + {"connectionStringSetting": "dummy_setting", + "dataType": DataType.UNDEFINED, + "tableName": "dummy_table", + "direction": BindingDirection.IN, + "dummyField": "dummy", + "name": "req", + "type": MYSQL_TRIGGER}) \ No newline at end of file From c3def194987aac021f70076d654e52248437927c Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:15:10 +0530 Subject: [PATCH 02/11] bring the import statement in the character limit --- azure/functions/decorators/function_app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure/functions/decorators/function_app.py b/azure/functions/decorators/function_app.py index 82186c06..29b47407 100644 --- a/azure/functions/decorators/function_app.py +++ b/azure/functions/decorators/function_app.py @@ -47,7 +47,8 @@ from .warmup import WarmUpTrigger from .._http_asgi import AsgiMiddleware from .._http_wsgi import WsgiMiddleware, Context -from azure.functions.decorators.mysql import MySqlInput, MySqlOutput, MySqlTrigger +from azure.functions.decorators.mysql import MySqlInput, MySqlOutput, \ + MySqlTrigger class Function(object): From 32f8a604454bc8cad9afe8bae98c15e0872b722b Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:57:52 +0530 Subject: [PATCH 03/11] Fix indentation and white spaces --- azure/functions/decorators/function_app.py | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/azure/functions/decorators/function_app.py b/azure/functions/decorators/function_app.py index 29b47407..ed54e96a 100644 --- a/azure/functions/decorators/function_app.py +++ b/azure/functions/decorators/function_app.py @@ -1444,14 +1444,14 @@ def decorator(): return decorator() return wrap - - def mysql_trigger(self, - arg_name: str, - table_name: str, - connection_string_setting: str, - leases_table_name: Optional[str] = None, - data_type: Optional[DataType] = None, - **kwargs) -> Callable[..., Any]: + + def mysql_trigger(self, + arg_name: str, + table_name: str, + connection_string_setting: str, + leases_table_name: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: """The mysql_trigger decorator adds :class:`MySqlTrigger` to the :class:`FunctionBuilder` object for building :class:`Function` object used in worker function @@ -1497,7 +1497,6 @@ def decorator(): return wrap - def generic_trigger(self, arg_name: str, type: str, @@ -3606,15 +3605,15 @@ def decorator(): return decorator() return wrap - + def mysql_input(self, - arg_name: str, - command_text: str, - connection_string_setting: str, - command_type: Optional[str] = 'Text', - parameters: Optional[str] = None, - data_type: Optional[DataType] = None, - **kwargs) -> Callable[..., Any]: + arg_name: str, + command_text: str, + connection_string_setting: str, + command_type: Optional[str] = 'Text', + parameters: Optional[str] = None, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: """The mysql_input decorator adds :class:`MySqlInput` to the :class:`FunctionBuilder` object for building :class:`Function` object used in worker function @@ -3662,13 +3661,13 @@ def decorator(): return decorator() return wrap - + def mysql_output(self, - arg_name: str, - command_text: str, - connection_string_setting: str, - data_type: Optional[DataType] = None, - **kwargs) -> Callable[..., Any]: + arg_name: str, + command_text: str, + connection_string_setting: str, + data_type: Optional[DataType] = None, + **kwargs) -> Callable[..., Any]: """The mysql_output decorator adds :class:`MySqlOutput` to the :class:`FunctionBuilder` object for building :class:`Function` object used in worker function @@ -3711,7 +3710,6 @@ def decorator(): return wrap - class SettingsApi(DecoratorApi, ABC): """Interface to extend for using existing settings decorator in functions.""" From afe67bc370d498afc6f096e0805991135f358b8c Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:29:29 +0530 Subject: [PATCH 04/11] Fix pipeline errors --- azure/functions/decorators/function_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/functions/decorators/function_app.py b/azure/functions/decorators/function_app.py index ed54e96a..f0feb470 100644 --- a/azure/functions/decorators/function_app.py +++ b/azure/functions/decorators/function_app.py @@ -48,7 +48,7 @@ from .._http_asgi import AsgiMiddleware from .._http_wsgi import WsgiMiddleware, Context from azure.functions.decorators.mysql import MySqlInput, MySqlOutput, \ - MySqlTrigger + MySqlTrigger class Function(object): From fca70c1fd32c83e7e32f19d0d0c4ee94d6e384c2 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:30:32 +0530 Subject: [PATCH 05/11] Fix newline at end of file From 9c1c021018381dd78ae9597b3140a9d3e1760cee Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:37:01 +0530 Subject: [PATCH 06/11] Fix indentation in test_decorators.py --- tests/decorators/test_decorators.py | 57 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index 3c6fc1af..e2926e25 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -2381,14 +2381,14 @@ def test_mysql_default_args(self): app = self.func_app @app.mysql_trigger(arg_name="trigger", - table_name="dummy_table", - connection_string_setting="dummy_setting") + table_name="dummy_table", + connection_string_setting="dummy_setting") @app.mysql_input(arg_name="in", - command_text="dummy_query", - connection_string_setting="dummy_setting") + command_text="dummy_query", + connection_string_setting="dummy_setting") @app.mysql_output(arg_name="out", - command_text="dummy_table", - connection_string_setting="dummy_setting") + command_text="dummy_table", + connection_string_setting="dummy_setting") def dummy(): pass @@ -2426,22 +2426,22 @@ def test_mysql_full_args(self): app = self.func_app @app.mysql_trigger(arg_name="trigger", - table_name="dummy_table", + table_name="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.STRING, + dummy_field="dummy") + @app.mysql_input(arg_name="in", + command_text="dummy_query", connection_string_setting="dummy_setting", + command_type="Text", + parameters="dummy_parameters", data_type=DataType.STRING, dummy_field="dummy") - @app.mysql_input(arg_name="in", - command_text="dummy_query", - connection_string_setting="dummy_setting", - command_type="Text", - parameters="dummy_parameters", - data_type=DataType.STRING, - dummy_field="dummy") @app.mysql_output(arg_name="out", - command_text="dummy_table", - connection_string_setting="dummy_setting", - data_type=DataType.STRING, - dummy_field="dummy") + command_text="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.STRING, + dummy_field="dummy") def dummy(): pass @@ -2486,8 +2486,8 @@ def test_mysql_trigger(self): app = self.func_app @app.mysql_trigger(arg_name="trigger", - table_name="dummy_table", - connection_string_setting="dummy_setting") + table_name="dummy_table", + connection_string_setting="dummy_setting") def dummy(): pass @@ -2508,11 +2508,11 @@ def test_mysql_input_binding(self): app = self.func_app @app.mysql_trigger(arg_name="trigger", - table_name="dummy_table", - connection_string_setting="dummy_setting") + table_name="dummy_table", + connection_string_setting="dummy_setting") @app.mysql_input(arg_name="in", - command_text="dummy_query", - connection_string_setting="dummy_setting") + command_text="dummy_query", + connection_string_setting="dummy_setting") def dummy(): pass @@ -2534,11 +2534,11 @@ def test_mysql_output_binding(self): app = self.func_app @app.mysql_trigger(arg_name="trigger", - table_name="dummy_table", - connection_string_setting="dummy_setting") + table_name="dummy_table", + connection_string_setting="dummy_setting") @app.mysql_output(arg_name="out", - command_text="dummy_table", - connection_string_setting="dummy_setting") + command_text="dummy_table", + connection_string_setting="dummy_setting") def dummy(): pass @@ -2554,4 +2554,3 @@ def dummy(): "commandText": "dummy_table", "connectionStringSetting": "dummy_setting", }) - From fba31ed2322bde6b33796b244b44268c0ce7d7b1 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:38:32 +0530 Subject: [PATCH 07/11] Fix newline at end of file From 6567248accd194527069f342b7e117900bc640c0 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:41:17 +0530 Subject: [PATCH 08/11] Fix indentation in MySQL test cases --- tests/decorators/test_mysql.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/decorators/test_mysql.py b/tests/decorators/test_mysql.py index 626e1ac4..17178557 100644 --- a/tests/decorators/test_mysql.py +++ b/tests/decorators/test_mysql.py @@ -11,10 +11,10 @@ class TestMySql(unittest.TestCase): def test_mysql_input_valid_creation(self): input = MySqlInput(name="req", - command_text="dummy_query", - connection_string_setting="dummy_setting", - data_type=DataType.UNDEFINED, - dummy_field="dummy") + command_text="dummy_query", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") self.assertEqual(input.get_binding_name(), "mysql") self.assertEqual(input.get_dict_repr(), {"commandText": "dummy_query", @@ -25,13 +25,13 @@ def test_mysql_input_valid_creation(self): "dummyField": "dummy", "name": "req", "type": MYSQL}) - + def test_mysql_output_valid_creation(self): output = MySqlOutput(name="req", - command_text="dummy_table", - connection_string_setting="dummy_setting", - data_type=DataType.UNDEFINED, - dummy_field="dummy") + command_text="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") self.assertEqual(output.get_binding_name(), "mysql") self.assertEqual(output.get_dict_repr(), {"commandText": "dummy_table", @@ -44,10 +44,10 @@ def test_mysql_output_valid_creation(self): def test_mysql_trigger_valid_creation(self): trigger = MySqlTrigger(name="req", - table_name="dummy_table", - connection_string_setting="dummy_setting", - data_type=DataType.UNDEFINED, - dummy_field="dummy") + table_name="dummy_table", + connection_string_setting="dummy_setting", + data_type=DataType.UNDEFINED, + dummy_field="dummy") self.assertEqual(trigger.get_binding_name(), "mysqlTrigger") self.assertEqual(trigger.get_dict_repr(), From 27ff717e4da49453945c0a926579882b9535d36d Mon Sep 17 00:00:00 2001 From: Gavin Aguiar <80794152+gavin-aguiar@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:08:15 -0600 Subject: [PATCH 09/11] Add newline at end of test_mysql.py file --- tests/decorators/test_mysql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/decorators/test_mysql.py b/tests/decorators/test_mysql.py index 17178557..8cd7b992 100644 --- a/tests/decorators/test_mysql.py +++ b/tests/decorators/test_mysql.py @@ -57,4 +57,5 @@ def test_mysql_trigger_valid_creation(self): "direction": BindingDirection.IN, "dummyField": "dummy", "name": "req", - "type": MYSQL_TRIGGER}) \ No newline at end of file + "type": MYSQL_TRIGGER}) + \ No newline at end of file From ff5337b5db64a1d78c45e0416862285f271c3225 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar <80794152+gavin-aguiar@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:29:59 -0600 Subject: [PATCH 10/11] Remove trailing whitespace and add newline --- tests/decorators/test_mysql.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/decorators/test_mysql.py b/tests/decorators/test_mysql.py index 8cd7b992..17178557 100644 --- a/tests/decorators/test_mysql.py +++ b/tests/decorators/test_mysql.py @@ -57,5 +57,4 @@ def test_mysql_trigger_valid_creation(self): "direction": BindingDirection.IN, "dummyField": "dummy", "name": "req", - "type": MYSQL_TRIGGER}) - \ No newline at end of file + "type": MYSQL_TRIGGER}) \ No newline at end of file From 4ba07e78db298480d036ada7648b327a21178eef Mon Sep 17 00:00:00 2001 From: Heena Gupta Date: Wed, 15 Jan 2025 23:28:35 +0530 Subject: [PATCH 11/11] add new lines --- azure/functions/decorators/mysql.py | 2 +- tests/decorators/test_mysql.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure/functions/decorators/mysql.py b/azure/functions/decorators/mysql.py index 2660c98b..531e255f 100644 --- a/azure/functions/decorators/mysql.py +++ b/azure/functions/decorators/mysql.py @@ -58,4 +58,4 @@ def __init__(self, self.table_name = table_name self.connection_string_setting = connection_string_setting self.leases_table_name = leases_table_name - super().__init__(name=name, data_type=data_type) \ No newline at end of file + super().__init__(name=name, data_type=data_type) diff --git a/tests/decorators/test_mysql.py b/tests/decorators/test_mysql.py index 17178557..588343ce 100644 --- a/tests/decorators/test_mysql.py +++ b/tests/decorators/test_mysql.py @@ -57,4 +57,4 @@ def test_mysql_trigger_valid_creation(self): "direction": BindingDirection.IN, "dummyField": "dummy", "name": "req", - "type": MYSQL_TRIGGER}) \ No newline at end of file + "type": MYSQL_TRIGGER})