From fd1619da91c8c5a46fc75babaf3f96fd4bc47adf Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 18:46:04 -0600 Subject: [PATCH 1/9] Unit tests fixes --- tests/decorators/test_dapr.py | 2 +- tests/decorators/test_decorators.py | 2 +- tests/decorators/test_function_app.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/decorators/test_dapr.py b/tests/decorators/test_dapr.py index d64287b3..794c82f0 100644 --- a/tests/decorators/test_dapr.py +++ b/tests/decorators/test_dapr.py @@ -7,7 +7,7 @@ DAPR_BINDING_TRIGGER, DAPR_INVOKE, DAPR_PUBLISH, DAPR_SECRET, \ DAPR_SERVICE_INVOCATION_TRIGGER, DAPR_STATE, DAPR_TOPIC_TRIGGER from azure.functions.decorators.function_app import FunctionApp -from tests.decorators.testutils import assert_json +from testutils import assert_json class TestDapr(unittest.TestCase): diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index d06fd3ae..37cc8501 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -12,7 +12,7 @@ from azure.functions.decorators.function_app import FunctionApp from azure.functions.decorators.http import HttpTrigger, HttpMethod from azure.functions.decorators.timer import TimerTrigger -from tests.decorators.testutils import assert_json +from testutils import assert_json class TestFunctionsApp(unittest.TestCase): diff --git a/tests/decorators/test_function_app.py b/tests/decorators/test_function_app.py index 5fe9317b..9e517b75 100644 --- a/tests/decorators/test_function_app.py +++ b/tests/decorators/test_function_app.py @@ -19,7 +19,7 @@ HttpMethod from azure.functions.decorators.retry_policy import RetryPolicy from tests.decorators.test_core import DummyTrigger -from tests.decorators.testutils import assert_json +from testutils import assert_json class TestFunction(unittest.TestCase): From 09279f3b1cfcc515b159fda0101779cf90b9e232 Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 18:48:03 -0600 Subject: [PATCH 2/9] Updated imports --- tests/decorators/test_function_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/decorators/test_function_app.py b/tests/decorators/test_function_app.py index 9e517b75..08b2e058 100644 --- a/tests/decorators/test_function_app.py +++ b/tests/decorators/test_function_app.py @@ -18,7 +18,7 @@ from azure.functions.decorators.http import HttpTrigger, HttpOutput, \ HttpMethod from azure.functions.decorators.retry_policy import RetryPolicy -from tests.decorators.test_core import DummyTrigger +from test_core import DummyTrigger from testutils import assert_json From e6486fab91cbd31b76c5f6cffeeca8fa4ac10088 Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 18:55:10 -0600 Subject: [PATCH 3/9] Removed testutils from test.decorators --- CODEOWNERS | 2 +- tests/decorators/test_dapr.py | 2 +- tests/decorators/test_decorators.py | 2 +- tests/decorators/test_function_app.py | 2 +- tests/decorators/testutils.py | 12 ------------ tests/testutils.py | 11 +++++++++++ 6 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 tests/decorators/testutils.py diff --git a/CODEOWNERS b/CODEOWNERS index d0f52dc5..f9288ca9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -9,4 +9,4 @@ # AZURE FUNCTIONS TEAM # For all file changes, github would automatically include the following people in the PRs. # -* @vrdmr @gavin-aguiar @YunchuWang @pdthummar +* @vrdmr @gavin-aguiar @YunchuWang @pdthummar @hallvictoria \ No newline at end of file diff --git a/tests/decorators/test_dapr.py b/tests/decorators/test_dapr.py index 794c82f0..eafeed4c 100644 --- a/tests/decorators/test_dapr.py +++ b/tests/decorators/test_dapr.py @@ -7,7 +7,7 @@ DAPR_BINDING_TRIGGER, DAPR_INVOKE, DAPR_PUBLISH, DAPR_SECRET, \ DAPR_SERVICE_INVOCATION_TRIGGER, DAPR_STATE, DAPR_TOPIC_TRIGGER from azure.functions.decorators.function_app import FunctionApp -from testutils import assert_json +from tests.testutils import assert_json class TestDapr(unittest.TestCase): diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index 37cc8501..0308ec3d 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -12,7 +12,7 @@ from azure.functions.decorators.function_app import FunctionApp from azure.functions.decorators.http import HttpTrigger, HttpMethod from azure.functions.decorators.timer import TimerTrigger -from testutils import assert_json +from tests.testutils import assert_json class TestFunctionsApp(unittest.TestCase): diff --git a/tests/decorators/test_function_app.py b/tests/decorators/test_function_app.py index 08b2e058..d7f08487 100644 --- a/tests/decorators/test_function_app.py +++ b/tests/decorators/test_function_app.py @@ -19,7 +19,7 @@ HttpMethod from azure.functions.decorators.retry_policy import RetryPolicy from test_core import DummyTrigger -from testutils import assert_json +from tests.testutils import assert_json class TestFunction(unittest.TestCase): diff --git a/tests/decorators/testutils.py b/tests/decorators/testutils.py deleted file mode 100644 index 6e85f9d1..00000000 --- a/tests/decorators/testutils.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. -import json - -from azure.functions.decorators.utils import StringifyEnumJsonEncoder - - -def assert_json(self, func, expected_dict): - self.assertEqual(json.dumps(json.loads(str(func)), sort_keys=True, - cls=StringifyEnumJsonEncoder), - json.dumps(expected_dict, sort_keys=True, - cls=StringifyEnumJsonEncoder)) diff --git a/tests/testutils.py b/tests/testutils.py index a144243c..1882b66f 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -1,5 +1,8 @@ +import json from typing import List +from azure.functions.decorators.utils import StringifyEnumJsonEncoder + class CollectionBytes: """The CollectionBytes class is used for generating a mock @@ -29,3 +32,11 @@ class CollectionSint64: """ def __init__(self, data: List[int]): self.sint64 = data + + +def assert_json(self, func, expected_dict): + self.assertEqual(json.dumps(json.loads(str(func)), sort_keys=True, + cls=StringifyEnumJsonEncoder), + json.dumps(expected_dict, sort_keys=True, + cls=StringifyEnumJsonEncoder)) + From 3902b3a4ba28bd0f09a6137544b2f9b0c3d6118f Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 18:57:19 -0600 Subject: [PATCH 4/9] Making imports relative --- tests/decorators/test_dapr.py | 2 +- tests/decorators/test_decorators.py | 2 +- tests/decorators/test_function_app.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/decorators/test_dapr.py b/tests/decorators/test_dapr.py index eafeed4c..6220e0f0 100644 --- a/tests/decorators/test_dapr.py +++ b/tests/decorators/test_dapr.py @@ -7,7 +7,7 @@ DAPR_BINDING_TRIGGER, DAPR_INVOKE, DAPR_PUBLISH, DAPR_SECRET, \ DAPR_SERVICE_INVOCATION_TRIGGER, DAPR_STATE, DAPR_TOPIC_TRIGGER from azure.functions.decorators.function_app import FunctionApp -from tests.testutils import assert_json +from ..testutils import assert_json class TestDapr(unittest.TestCase): diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index 0308ec3d..b685a268 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -12,7 +12,7 @@ from azure.functions.decorators.function_app import FunctionApp from azure.functions.decorators.http import HttpTrigger, HttpMethod from azure.functions.decorators.timer import TimerTrigger -from tests.testutils import assert_json +from ..testutils import assert_json class TestFunctionsApp(unittest.TestCase): diff --git a/tests/decorators/test_function_app.py b/tests/decorators/test_function_app.py index d7f08487..e679570d 100644 --- a/tests/decorators/test_function_app.py +++ b/tests/decorators/test_function_app.py @@ -19,7 +19,7 @@ HttpMethod from azure.functions.decorators.retry_policy import RetryPolicy from test_core import DummyTrigger -from tests.testutils import assert_json +from ..testutils import assert_json class TestFunction(unittest.TestCase): From 0f73ddf0f1064ce530a1687bc68f75cbebc63757 Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 19:19:17 -0600 Subject: [PATCH 5/9] Moved testsutils inside utils dir --- tests/decorators/test_dapr.py | 2 +- tests/decorators/test_decorators.py | 2 +- tests/decorators/test_function_app.py | 2 +- tests/test_eventhub.py | 2 +- tests/test_kafka.py | 2 +- tests/test_servicebus.py | 2 +- tests/utils/__init__.py | 0 tests/{ => utils}/testutils.py | 0 8 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 tests/utils/__init__.py rename tests/{ => utils}/testutils.py (100%) diff --git a/tests/decorators/test_dapr.py b/tests/decorators/test_dapr.py index 6220e0f0..522f1b54 100644 --- a/tests/decorators/test_dapr.py +++ b/tests/decorators/test_dapr.py @@ -7,7 +7,7 @@ DAPR_BINDING_TRIGGER, DAPR_INVOKE, DAPR_PUBLISH, DAPR_SECRET, \ DAPR_SERVICE_INVOCATION_TRIGGER, DAPR_STATE, DAPR_TOPIC_TRIGGER from azure.functions.decorators.function_app import FunctionApp -from ..testutils import assert_json +from tests.utils.testutils import assert_json class TestDapr(unittest.TestCase): diff --git a/tests/decorators/test_decorators.py b/tests/decorators/test_decorators.py index b685a268..97c50a7a 100644 --- a/tests/decorators/test_decorators.py +++ b/tests/decorators/test_decorators.py @@ -12,7 +12,7 @@ from azure.functions.decorators.function_app import FunctionApp from azure.functions.decorators.http import HttpTrigger, HttpMethod from azure.functions.decorators.timer import TimerTrigger -from ..testutils import assert_json +from tests.utils.testutils import assert_json class TestFunctionsApp(unittest.TestCase): diff --git a/tests/decorators/test_function_app.py b/tests/decorators/test_function_app.py index e679570d..1d72a813 100644 --- a/tests/decorators/test_function_app.py +++ b/tests/decorators/test_function_app.py @@ -19,7 +19,7 @@ HttpMethod from azure.functions.decorators.retry_policy import RetryPolicy from test_core import DummyTrigger -from ..testutils import assert_json +from tests.utils.testutils import assert_json class TestFunction(unittest.TestCase): diff --git a/tests/test_eventhub.py b/tests/test_eventhub.py index 897e27fd..737438f1 100644 --- a/tests/test_eventhub.py +++ b/tests/test_eventhub.py @@ -11,7 +11,7 @@ import azure.functions.eventhub as azf_eh import azure.functions.meta as meta -from .testutils import CollectionBytes, CollectionString +from tests.utils.testutils import CollectionBytes, CollectionString class TestEventHub(unittest.TestCase): diff --git a/tests/test_kafka.py b/tests/test_kafka.py index 16ace480..51187829 100644 --- a/tests/test_kafka.py +++ b/tests/test_kafka.py @@ -10,7 +10,7 @@ import azure.functions.kafka as azf_ka import azure.functions.meta as meta -from .testutils import CollectionBytes, CollectionString, CollectionSint64 +from tests.utils.testutils import CollectionBytes, CollectionString, CollectionSint64 class Kafka(unittest.TestCase): diff --git a/tests/test_servicebus.py b/tests/test_servicebus.py index 33357878..651c4983 100644 --- a/tests/test_servicebus.py +++ b/tests/test_servicebus.py @@ -10,7 +10,7 @@ import azure.functions.servicebus as azf_sb from azure.functions import meta -from .testutils import CollectionBytes, CollectionString, CollectionSint64 +from tests.utils.testutils import CollectionBytes, CollectionString, CollectionSint64 class TestServiceBus(unittest.TestCase): diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/testutils.py b/tests/utils/testutils.py similarity index 100% rename from tests/testutils.py rename to tests/utils/testutils.py From 257c947ebdb33997c521581fded39805b9ee8afc Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 19:49:37 -0600 Subject: [PATCH 6/9] Updated CI pipeline --- .github/workflows/gh-tests-ci.yml | 2 +- tests/test_kafka.py | 3 ++- tests/test_servicebus.py | 3 ++- tests/utils/testutils.py | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gh-tests-ci.yml b/.github/workflows/gh-tests-ci.yml index 0338ef9a..57001ade 100644 --- a/.github/workflows/gh-tests-ci.yml +++ b/.github/workflows/gh-tests-ci.yml @@ -25,7 +25,7 @@ jobs: python -m pip install -U -e .[dev] - name: Test with pytest run: | - pytest --cache-clear --cov=./azure --cov-report=xml --cov-branch tests + python -m pytest --cache-clear --cov=./azure --cov-report=xml --cov-branch tests - name: Codecov if: ${{ matrix.python-version }} == 3.9 uses: codecov/codecov-action@v2 diff --git a/tests/test_kafka.py b/tests/test_kafka.py index 51187829..6776c946 100644 --- a/tests/test_kafka.py +++ b/tests/test_kafka.py @@ -10,7 +10,8 @@ import azure.functions.kafka as azf_ka import azure.functions.meta as meta -from tests.utils.testutils import CollectionBytes, CollectionString, CollectionSint64 +from tests.utils.testutils import (CollectionBytes, CollectionString, + CollectionSint64) class Kafka(unittest.TestCase): diff --git a/tests/test_servicebus.py b/tests/test_servicebus.py index 651c4983..b02635de 100644 --- a/tests/test_servicebus.py +++ b/tests/test_servicebus.py @@ -10,7 +10,8 @@ import azure.functions.servicebus as azf_sb from azure.functions import meta -from tests.utils.testutils import CollectionBytes, CollectionString, CollectionSint64 +from tests.utils.testutils import (CollectionBytes, CollectionString, + CollectionSint64) class TestServiceBus(unittest.TestCase): diff --git a/tests/utils/testutils.py b/tests/utils/testutils.py index 1882b66f..b130ed2f 100644 --- a/tests/utils/testutils.py +++ b/tests/utils/testutils.py @@ -39,4 +39,3 @@ def assert_json(self, func, expected_dict): cls=StringifyEnumJsonEncoder), json.dumps(expected_dict, sort_keys=True, cls=StringifyEnumJsonEncoder)) - From 925a11a44fd2359a7415a3dd1d02b42e3bce094b Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 20:00:19 -0600 Subject: [PATCH 7/9] Removed pytest-cov from pipeline --- .github/workflows/gh-tests-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/gh-tests-ci.yml b/.github/workflows/gh-tests-ci.yml index 57001ade..899c18f5 100644 --- a/.github/workflows/gh-tests-ci.yml +++ b/.github/workflows/gh-tests-ci.yml @@ -21,7 +21,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest-cov python -m pip install -U -e .[dev] - name: Test with pytest run: | From 04caf3959daeb727f0f785ac444483b9987162c0 Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 20:51:45 -0600 Subject: [PATCH 8/9] Added a schedule for the ci pipeline --- .github/workflows/gh-tests-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gh-tests-ci.yml b/.github/workflows/gh-tests-ci.yml index 899c18f5..11d9d8a4 100644 --- a/.github/workflows/gh-tests-ci.yml +++ b/.github/workflows/gh-tests-ci.yml @@ -5,6 +5,9 @@ on: push: pull_request: branches: [ dev ] + schedule: + # Monday to Thursday 1 AM PDT build + - cron: "0 8 * * 1,2,3,4" jobs: build: From 41294dc0fd259f2f50867145c7826ac3e61bcb47 Mon Sep 17 00:00:00 2001 From: gavin-aguiar Date: Tue, 30 Jan 2024 22:31:31 -0600 Subject: [PATCH 9/9] Updated pipeline versions --- .github/workflows/gh-tests-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-tests-ci.yml b/.github/workflows/gh-tests-ci.yml index 11d9d8a4..d2350105 100644 --- a/.github/workflows/gh-tests-ci.yml +++ b/.github/workflows/gh-tests-ci.yml @@ -16,9 +16,9 @@ jobs: matrix: python_version: [3.7, 3.8, 3.9, "3.10", "3.11"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Install dependencies