Skip to content

Commit 32ae79a

Browse files
authored
Unit tests fixes (#204)
* Unit tests fixes * Updated imports * Removed testutils from test.decorators * Making imports relative * Moved testsutils inside utils dir * Updated CI pipeline * Removed pytest-cov from pipeline * Added a schedule for the ci pipeline * Updated pipeline versions
1 parent 1a43888 commit 32ae79a

File tree

11 files changed

+26
-24
lines changed

11 files changed

+26
-24
lines changed

.github/workflows/gh-tests-ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
push:
66
pull_request:
77
branches: [ dev ]
8+
schedule:
9+
# Monday to Thursday 1 AM PDT build
10+
- cron: "0 8 * * 1,2,3,4"
811

912
jobs:
1013
build:
@@ -13,19 +16,18 @@ jobs:
1316
matrix:
1417
python_version: [3.7, 3.8, 3.9, "3.10", "3.11"]
1518
steps:
16-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
1720
- name: Set up Python ${{ matrix.python_version }}
18-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v5
1922
with:
2023
python-version: ${{ matrix.python_version }}
2124
- name: Install dependencies
2225
run: |
2326
python -m pip install --upgrade pip
24-
python -m pip install pytest-cov
2527
python -m pip install -U -e .[dev]
2628
- name: Test with pytest
2729
run: |
28-
pytest --cache-clear --cov=./azure --cov-report=xml --cov-branch tests
30+
python -m pytest --cache-clear --cov=./azure --cov-report=xml --cov-branch tests
2931
- name: Codecov
3032
if: ${{ matrix.python-version }} == 3.9
3133
uses: codecov/codecov-action@v2

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
# AZURE FUNCTIONS TEAM
1010
# For all file changes, github would automatically include the following people in the PRs.
1111
#
12-
* @vrdmr @gavin-aguiar @YunchuWang @pdthummar
12+
* @vrdmr @gavin-aguiar @YunchuWang @pdthummar @hallvictoria

tests/decorators/test_dapr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
DAPR_BINDING_TRIGGER, DAPR_INVOKE, DAPR_PUBLISH, DAPR_SECRET, \
88
DAPR_SERVICE_INVOCATION_TRIGGER, DAPR_STATE, DAPR_TOPIC_TRIGGER
99
from azure.functions.decorators.function_app import FunctionApp
10-
from tests.decorators.testutils import assert_json
10+
from tests.utils.testutils import assert_json
1111

1212

1313
class TestDapr(unittest.TestCase):

tests/decorators/test_decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from azure.functions.decorators.function_app import FunctionApp
1313
from azure.functions.decorators.http import HttpTrigger, HttpMethod
1414
from azure.functions.decorators.timer import TimerTrigger
15-
from tests.decorators.testutils import assert_json
15+
from tests.utils.testutils import assert_json
1616

1717

1818
class TestFunctionsApp(unittest.TestCase):

tests/decorators/test_function_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from azure.functions.decorators.http import HttpTrigger, HttpOutput, \
1919
HttpMethod
2020
from azure.functions.decorators.retry_policy import RetryPolicy
21-
from tests.decorators.test_core import DummyTrigger
22-
from tests.decorators.testutils import assert_json
21+
from test_core import DummyTrigger
22+
from tests.utils.testutils import assert_json
2323

2424

2525
class TestFunction(unittest.TestCase):

tests/decorators/testutils.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/test_eventhub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import azure.functions.eventhub as azf_eh
1212
import azure.functions.meta as meta
1313

14-
from .testutils import CollectionBytes, CollectionString
14+
from tests.utils.testutils import CollectionBytes, CollectionString
1515

1616

1717
class TestEventHub(unittest.TestCase):

tests/test_kafka.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import azure.functions.kafka as azf_ka
1111
import azure.functions.meta as meta
1212

13-
from .testutils import CollectionBytes, CollectionString, CollectionSint64
13+
from tests.utils.testutils import (CollectionBytes, CollectionString,
14+
CollectionSint64)
1415

1516

1617
class Kafka(unittest.TestCase):

tests/test_servicebus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import azure.functions.servicebus as azf_sb
1111
from azure.functions import meta
1212

13-
from .testutils import CollectionBytes, CollectionString, CollectionSint64
13+
from tests.utils.testutils import (CollectionBytes, CollectionString,
14+
CollectionSint64)
1415

1516

1617
class TestServiceBus(unittest.TestCase):

tests/utils/__init__.py

Whitespace-only changes.

tests/testutils.py renamed to tests/utils/testutils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import json
12
from typing import List
23

4+
from azure.functions.decorators.utils import StringifyEnumJsonEncoder
5+
36

47
class CollectionBytes:
58
"""The CollectionBytes class is used for generating a mock
@@ -29,3 +32,10 @@ class CollectionSint64:
2932
"""
3033
def __init__(self, data: List[int]):
3134
self.sint64 = data
35+
36+
37+
def assert_json(self, func, expected_dict):
38+
self.assertEqual(json.dumps(json.loads(str(func)), sort_keys=True,
39+
cls=StringifyEnumJsonEncoder),
40+
json.dumps(expected_dict, sort_keys=True,
41+
cls=StringifyEnumJsonEncoder))

0 commit comments

Comments
 (0)