Skip to content

Commit

Permalink
Fix the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ninghu committed Jun 19, 2024
1 parent 4aa135f commit e5174c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/promptflow-azure/promptflow/azure/_utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import jwt

from promptflow.azure._utils._token_cache import ArmTokenCache
from promptflow.core._connection_provider._utils import get_arm_token, get_token

from ._token_cache import ArmTokenCache


def is_arm_id(obj) -> bool:
return isinstance(obj, str) and obj.startswith("azureml://")
Expand Down
8 changes: 7 additions & 1 deletion src/promptflow-evals/tests/evals/unittests/test_eval_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import MagicMock, patch
from uuid import uuid4

import jwt
import pytest

import promptflow.evals.evaluate._utils as ev_utils
Expand All @@ -18,8 +19,13 @@ def setup_data():
Singleton._instances.clear()


def generate_mock_token():
expiration_time = time.time() + 3600 # 1 hour in the future
return jwt.encode({"exp": expiration_time}, "secret", algorithm="HS256")


@pytest.mark.unittest
@patch.object(ArmTokenCache, "_fetch_token")
@patch.object(ArmTokenCache, "_fetch_token", return_value=generate_mock_token())
class TestEvalRun:
"""Unit tests for the eval-run object."""

Expand Down

0 comments on commit e5174c1

Please sign in to comment.