Skip to content

Unit tests fixes #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/gh-tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,11 +24,10 @@ 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: |
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
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/decorators/test_dapr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 tests.utils.testutils import assert_json


class TestDapr(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/decorators/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 tests.utils.testutils import assert_json


class TestFunctionsApp(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/decorators/test_function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
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 tests.decorators.testutils import assert_json
from test_core import DummyTrigger
from tests.utils.testutils import assert_json


class TestFunction(unittest.TestCase):
Expand Down
12 changes: 0 additions & 12 deletions tests/decorators/testutils.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_eventhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
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):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_servicebus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
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):
Expand Down
Empty file added tests/utils/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions tests/testutils.py → tests/utils/testutils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,3 +32,10 @@ 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))