Skip to content

Commit e4cfa9a

Browse files
committed
[change] Added additional checks for pytest-vcr and vcrpy dependencies
1 parent 69f757e commit e4cfa9a

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

pyatlan/errors.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ def __str__(self):
5151
)
5252

5353

54+
class DependencyNotFoundError(Exception):
55+
"""
56+
Raised when a required external dependency is not installed.
57+
58+
This exception is typically used to indicate that an optional library
59+
or plugin needed for a specific feature is missing.
60+
"""
61+
62+
pass
63+
64+
5465
class ApiConnectionError(AtlanError):
5566
"""Error that occurs when there is an intermittent issue with the API, such as a network outage or an inability
5667
to connect due to an incorrect URL."""

pyatlan/test_utils/base_vcr.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,27 @@
33

44
import pkg_resources # type: ignore[import-untyped]
55

6-
from pyatlan.utils import DependencyNotFoundError
6+
from pyatlan.errors import DependencyNotFoundError
77

8+
# Check if pytest-vcr plugin is installed
89
try:
9-
# Check if pytest-vcr plugin is installed
1010
pkg_resources.get_distribution("pytest-vcr")
1111
except pkg_resources.DistributionNotFound:
12-
raise DependencyNotFoundError("pytest-vcr")
12+
raise DependencyNotFoundError(
13+
"pytest-vcr plugin is not installed. Please install pytest-vcr."
14+
)
15+
16+
# Check if vcrpy is installed and ensure the version is 6.0.x
17+
try:
18+
vcr_version = pkg_resources.get_distribution("vcrpy").version
19+
if not vcr_version.startswith("6.0"):
20+
raise DependencyNotFoundError(
21+
f"vcrpy version 6.0.x is required, but found {vcr_version}. Please install the correct version."
22+
)
23+
except pkg_resources.DistributionNotFound:
24+
raise DependencyNotFoundError(
25+
"vcrpy version 6.0.x is not installed. Please install vcrpy version 6.0.x."
26+
)
1327

1428
import json
1529
import os

pyatlan/utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,3 @@ def validate_single_required_field(field_names: List[str], values: List[Any]):
471471
raise ValueError(
472472
f"Only one of the following parameters are allowed: {', '.join(names)}"
473473
)
474-
475-
476-
class DependencyNotFoundError(Exception):
477-
def __init__(self, dependency):
478-
super().__init__(
479-
f"{dependency} is not installed, but it is required to use this module. Please install {dependency}."
480-
)

0 commit comments

Comments
 (0)