Skip to content

Commit

Permalink
Add a fixture to skip databricks tests if databricks is not installed.
Browse files Browse the repository at this point in the history
databricks units tests will be skipped in the morpheus-conda testing.

Signed-off-by: Anuradha Karuppiah <[email protected]>
  • Loading branch information
AnuradhaKaruppiah committed Oct 10, 2024
1 parent 6b38de4 commit 8e9450b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,16 @@ def langchain_nvidia_ai_endpoints_fixture(fail_missing: bool):
fail_missing=fail_missing)


@pytest.fixture(name="databricks", scope='session')
def databricks_fixture(fail_missing: bool):
"""
Fixture to ensure databricks is installed
"""
yield import_or_skip("databricks.connect",
reason=OPT_DEP_SKIP_REASON.format(package="databricks-connect"),
fail_missing=fail_missing)


@pytest.mark.usefixtures("openai")
@pytest.fixture(name="mock_chat_completion")
def mock_chat_completion_fixture():
Expand Down
25 changes: 25 additions & 0 deletions tests/morpheus/stages/databricks/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest


# Override fixtures from parent setting autouse to True
@pytest.fixture(name="databricks", autouse=True, scope='session')
def databricks_fixture(databricks):
"""
All of the tests in this subdir require databricks
"""
yield databricks
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

try:
import databricks.connect # pylint: disable=unused-import # noqa
except ImportError:
import pytest
pytest.skip("databricks-connect not installed", allow_module_level=True)

from unittest.mock import patch

from _utils import assert_results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

try:
import databricks.connect # pylint: disable=unused-import # noqa
except ImportError:
import pytest
pytest.skip("databricks-connect not installed", allow_module_level=True)

from unittest import mock
from unittest.mock import patch

Expand Down

0 comments on commit 8e9450b

Please sign in to comment.