diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d26c668..f10f70f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,8 @@ jobs: - name: Validate version sync run: | - CORE_VERSION=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('packages/deepfreeze-core/deepfreeze_core/__init__.py').read()).group(1))") - CLI_VERSION=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('packages/deepfreeze-cli/deepfreeze/__init__.py').read()).group(1))") + CORE_VERSION=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('packages/elastic-deepfreeze-core/elastic_deepfreeze_core/__init__.py').read()).group(1))") + CLI_VERSION=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('packages/elastic-deepfreeze-cli/elastic_deepfreeze/__init__.py').read()).group(1))") TAG_VERSION=${GITHUB_REF#refs/tags/v} echo "Core version: $CORE_VERSION" @@ -28,8 +28,8 @@ jobs: if [ "$CORE_VERSION" != "$CLI_VERSION" ]; then echo "ERROR: Version mismatch between packages!" - echo " deepfreeze-core: $CORE_VERSION" - echo " deepfreeze-cli: $CLI_VERSION" + echo " elastic-deepfreeze-core: $CORE_VERSION" + echo " elastic-deepfreeze-cli: $CLI_VERSION" exit 1 fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e8febf..a7451ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,17 +21,17 @@ jobs: - name: Install dependencies run: | pip install hatch - pip install -e packages/deepfreeze-core[dev] - pip install -e packages/deepfreeze-cli[dev] + pip install -e packages/elastic-deepfreeze-core[dev] + pip install -e packages/elastic-deepfreeze-cli[dev] - name: Run linting run: | - cd packages/deepfreeze-core && ruff check deepfreeze_core/ - cd ../deepfreeze-cli && ruff check deepfreeze/ + cd packages/elastic-deepfreeze-core && ruff check elastic_deepfreeze_core/ + cd ../elastic-deepfreeze-cli && ruff check elastic_deepfreeze/ - name: Run tests run: | - pytest tests/ -v --cov=deepfreeze_core --cov=deepfreeze --cov-report=xml + pytest tests/ -v --cov=elastic_deepfreeze_core --cov=elastic_deepfreeze --cov-report=xml - name: Upload coverage uses: codecov/codecov-action@v4 diff --git a/README.md b/README.md index 63b0190..c37de9c 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,25 @@ See Elastic Search Labs blog post at https://www.elastic.co/search-labs/blog/s3- This repository contains two packages: -### deepfreeze-core +### elastic-deepfreeze-core Core library providing the business logic for deepfreeze operations. Used by both the standalone CLI and Elasticsearch Curator. ```bash -pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/deepfreeze-core +pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/elastic-deepfreeze-core ``` -[View deepfreeze-core documentation](packages/deepfreeze-core/README.md) +[View elastic-deepfreeze-core documentation](packages/elastic-deepfreeze-core/README.md) -### deepfreeze-cli +### elastic-deepfreeze-cli Standalone CLI tool for managing Elasticsearch S3 Glacier archives. ```bash -pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/deepfreeze-cli +pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/elastic-deepfreeze-cli ``` -[View deepfreeze-cli documentation](packages/deepfreeze-cli/README.md) +[View elastic-deepfreeze-cli documentation](packages/elastic-deepfreeze-cli/README.md) ## Features @@ -44,7 +44,7 @@ pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/ 1. Install the CLI: ```bash - pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/deepfreeze-cli + pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/elastic-deepfreeze-cli ``` 2. Create a configuration file (`config.yml`): @@ -74,7 +74,11 @@ pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/ ## Integration with Curator -Elasticsearch Curator can use deepfreeze-core as a dependency. See the [Curator documentation](https://github.com/wortmanb/curator) for integration details. +Elasticsearch Curator can use elastic-deepfreeze-core as a dependency. See the [Curator documentation](https://github.com/wortmanb/curator) for integration details. + +## Why "elastic-deepfreeze-*"? + +The package names include the `elastic-` prefix to prevent dependency confusion attacks. The original names (`deepfreeze-core`, `deepfreeze-cli`) were vulnerable to name squatting on PyPI. By using a scoped prefix that we control, we ensure that `pip install` will fetch the authentic packages from the Elastic organization. ## Development @@ -86,8 +90,8 @@ git clone https://github.com/elastic/deepfreeze.git cd deepfreeze # Install both packages in development mode -pip install -e packages/deepfreeze-core[dev] -pip install -e packages/deepfreeze-cli[dev] +pip install -e packages/elastic-deepfreeze-core[dev] +pip install -e packages/elastic-deepfreeze-cli[dev] # Run tests pytest tests/ @@ -98,14 +102,14 @@ pytest tests/ ``` deepfreeze/ ├── packages/ -│ ├── deepfreeze-core/ # Core library -│ │ └── deepfreeze_core/ -│ └── deepfreeze-cli/ # Standalone CLI -│ └── deepfreeze/ +│ ├── elastic-deepfreeze-core/ # Core library +│ │ └── elastic_deepfreeze_core/ +│ └── elastic-deepfreeze-cli/ # Standalone CLI +│ └── elastic_deepfreeze/ ├── tests/ -│ ├── core/ # Core library tests -│ └── cli/ # CLI tests -└── .github/workflows/ # CI/CD +│ ├── core/ # Core library tests +│ └── cli/ # CLI tests +└── .github/workflows/ # CI/CD ``` ## License diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/__init__.py b/packages/deepfreeze-core/deepfreeze_core/actions/__init__.py deleted file mode 100644 index f7c8ea3..0000000 --- a/packages/deepfreeze-core/deepfreeze_core/actions/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Deepfreeze action modules - -This module exports all action classes for the standalone deepfreeze package. -Each action class provides do_action() and do_dry_run() methods for performing -deepfreeze operations. -""" - -from deepfreeze_core.actions.cleanup import Cleanup -from deepfreeze_core.actions.refreeze import Refreeze -from deepfreeze_core.actions.repair_metadata import RepairMetadata -from deepfreeze_core.actions.rotate import Rotate -from deepfreeze_core.actions.setup import Setup -from deepfreeze_core.actions.status import Status -from deepfreeze_core.actions.thaw import Thaw - -__all__ = [ - "Setup", - "Status", - "Rotate", - "Thaw", - "Refreeze", - "Cleanup", - "RepairMetadata", -] diff --git a/packages/deepfreeze-cli/README.md b/packages/elastic-deepfreeze-cli/README.md similarity index 89% rename from packages/deepfreeze-cli/README.md rename to packages/elastic-deepfreeze-cli/README.md index df35b38..a8f56c5 100644 --- a/packages/deepfreeze-cli/README.md +++ b/packages/elastic-deepfreeze-cli/README.md @@ -1,4 +1,4 @@ -# Deepfreeze +# Elastic Deepfreeze CLI Standalone Elasticsearch S3 Glacier archival and lifecycle management tool. @@ -18,24 +18,16 @@ Deepfreeze provides cost-effective S3 Glacier archival and lifecycle management ## Installation -### From PyPI (when published) +### From PyPI ```bash -pip install deepfreeze-cli +pip install elastic-deepfreeze-cli ``` ### From Source ```bash -# Clone the repository -git clone https://github.com/wortmanb/curator.git -cd curator/deepfreeze - -# Install in development mode -pip install -e . - -# Or install with development dependencies -pip install -e ".[dev]" +pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/elastic-deepfreeze-cli ``` ### Verify Installation @@ -54,8 +46,7 @@ deepfreeze --help - Elasticsearch 8.x cluster - AWS credentials configured (for S3 access) - Required Python packages (installed automatically): - - elasticsearch8 - - boto3 + - elastic-deepfreeze-core - click - rich - voluptuous @@ -245,7 +236,7 @@ pip install -e ".[dev]" pytest # Run with coverage -pytest --cov=deepfreeze --cov-report=term-missing +pytest --cov=elastic_deepfreeze --cov-report=term-missing # Run specific test file pytest tests/test_actions.py @@ -257,14 +248,9 @@ pytest tests/test_actions.py - No live Elasticsearch or AWS connection required - All tests run in isolation -## Independence from Curator - -Deepfreeze is a standalone package that operates independently of Elasticsearch Curator. It: +## Why "elastic-deepfreeze-cli"? -- Has no imports from the curator package -- Uses its own Elasticsearch client wrapper (not es_client.builder) -- Maintains its own exception classes -- Can be installed and run without curator +The package name includes the `elastic-` prefix to prevent dependency confusion attacks. See the [main README](../../README.md) for details. ## License diff --git a/packages/deepfreeze-cli/config.yml.example b/packages/elastic-deepfreeze-cli/config.yml.example similarity index 100% rename from packages/deepfreeze-cli/config.yml.example rename to packages/elastic-deepfreeze-cli/config.yml.example diff --git a/packages/deepfreeze-cli/deepfreeze/__init__.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/__init__.py similarity index 98% rename from packages/deepfreeze-cli/deepfreeze/__init__.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/__init__.py index b57cde6..bf73fea 100644 --- a/packages/deepfreeze-cli/deepfreeze/__init__.py +++ b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/__init__.py @@ -11,7 +11,7 @@ __version__ = "1.0.1" # Re-export everything from deepfreeze-core for backward compatibility -from deepfreeze_core import ( +from elastic_deepfreeze_core import ( PROVIDERS, SETTINGS_ID, # Constants diff --git a/packages/deepfreeze-cli/deepfreeze/cli/__init__.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/__init__.py similarity index 75% rename from packages/deepfreeze-cli/deepfreeze/cli/__init__.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/__init__.py index 7c9b004..029c852 100644 --- a/packages/deepfreeze-cli/deepfreeze/cli/__init__.py +++ b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/__init__.py @@ -3,6 +3,6 @@ This module provides the command-line interface for the standalone deepfreeze package. """ -from deepfreeze.cli.main import cli +from elastic_deepfreeze.cli.main import cli __all__ = ["cli"] diff --git a/packages/deepfreeze-cli/deepfreeze/cli/main.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/main.py similarity index 97% rename from packages/deepfreeze-cli/deepfreeze/cli/main.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/main.py index 2cd8133..562e8f8 100644 --- a/packages/deepfreeze-cli/deepfreeze/cli/main.py +++ b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/cli/main.py @@ -10,10 +10,10 @@ from pathlib import Path import click -from deepfreeze_core import ActionError, DeepfreezeException, create_es_client +from elastic_deepfreeze_core import ActionError, DeepfreezeException, create_es_client -from deepfreeze import __version__ -from deepfreeze.config import ( +from elastic_deepfreeze import __version__ +from elastic_deepfreeze.config import ( configure_logging, get_elasticsearch_config, load_config, @@ -302,7 +302,7 @@ def setup( - The template will be updated to use the specified ILM policy - Ensures new indices will automatically use the deepfreeze ILM policy """ - from deepfreeze_core.actions import Setup + from elastic_deepfreeze_core.actions import Setup client = get_client_from_context(ctx) @@ -374,7 +374,7 @@ def rotate( """ Deepfreeze rotation (add a new repo and age oldest off) """ - from deepfreeze_core.actions import Rotate + from elastic_deepfreeze_core.actions import Rotate client = get_client_from_context(ctx) @@ -465,7 +465,7 @@ def status( By default, all sections are displayed. Use section flags (-r, -t, -b, -i, -c) to show specific sections only. Multiple section flags can be combined. """ - from deepfreeze_core.actions import Status + from elastic_deepfreeze_core.actions import Status client = get_client_from_context(ctx) @@ -516,7 +516,7 @@ def cleanup( """ Clean up expired thawed repositories """ - from deepfreeze_core.actions import Cleanup + from elastic_deepfreeze_core.actions import Cleanup client = get_client_from_context(ctx) @@ -582,7 +582,7 @@ def refreeze( deepfreeze refreeze """ - from deepfreeze_core.actions import Refreeze + from elastic_deepfreeze_core.actions import Refreeze client = get_client_from_context(ctx) @@ -735,7 +735,7 @@ def thaw( """ from datetime import datetime as dt - from deepfreeze_core.actions import Thaw + from elastic_deepfreeze_core.actions import Thaw # Validate mutual exclusivity # Note: check_status can be None (not provided), "" (flag without value), or a string ID @@ -833,7 +833,7 @@ def repair_metadata(ctx, porcelain): Use --dry-run to see what would be changed without making modifications. """ - from deepfreeze_core.actions import RepairMetadata + from elastic_deepfreeze_core.actions import RepairMetadata client = get_client_from_context(ctx) diff --git a/packages/deepfreeze-cli/deepfreeze/config.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/config.py similarity index 98% rename from packages/deepfreeze-cli/deepfreeze/config.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/config.py index 86b6230..273462c 100644 --- a/packages/deepfreeze-cli/deepfreeze/config.py +++ b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/config.py @@ -11,7 +11,7 @@ from typing import Any, Optional import yaml -from deepfreeze_core import ActionError +from elastic_deepfreeze_core import ActionError # Environment variable prefix for deepfreeze configuration ENV_PREFIX = "DEEPFREEZE_" @@ -267,7 +267,7 @@ def configure_logging(config: dict) -> None: logger.propagate = False # Don't propagate to root logger (prevents duplicates) # Configure deepfreeze_core logger the same way - core_logger = logging.getLogger("deepfreeze_core") + core_logger = logging.getLogger("elastic_deepfreeze_core") core_logger.setLevel(level) core_logger.handlers = handlers core_logger.propagate = False diff --git a/packages/deepfreeze-cli/deepfreeze/defaults/__init__.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/defaults/__init__.py similarity index 100% rename from packages/deepfreeze-cli/deepfreeze/defaults/__init__.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/defaults/__init__.py diff --git a/packages/deepfreeze-cli/deepfreeze/validators/__init__.py b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/validators/__init__.py similarity index 99% rename from packages/deepfreeze-cli/deepfreeze/validators/__init__.py rename to packages/elastic-deepfreeze-cli/elastic_deepfreeze/validators/__init__.py index 228a9bd..c6fa9b7 100644 --- a/packages/deepfreeze-cli/deepfreeze/validators/__init__.py +++ b/packages/elastic-deepfreeze-cli/elastic_deepfreeze/validators/__init__.py @@ -7,7 +7,7 @@ from voluptuous import Schema -from deepfreeze import defaults +from elastic_deepfreeze import defaults # Deepfreeze action option schemas # Each schema lists the option defaults that apply to that action diff --git a/packages/deepfreeze-cli/pyproject.toml b/packages/elastic-deepfreeze-cli/pyproject.toml similarity index 89% rename from packages/deepfreeze-cli/pyproject.toml rename to packages/elastic-deepfreeze-cli/pyproject.toml index 3ba233a..9fae489 100644 --- a/packages/deepfreeze-cli/pyproject.toml +++ b/packages/elastic-deepfreeze-cli/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "deepfreeze-cli" +name = "elastic-deepfreeze-cli" version = "1.0.0" description = "Standalone Elasticsearch S3 Glacier archival and lifecycle management tool" readme = "README.md" @@ -14,6 +14,7 @@ authors = [ ] keywords = [ "elasticsearch", + "elastic", "s3", "glacier", "archival", @@ -36,7 +37,7 @@ classifiers = [ "Topic :: Database", ] dependencies = [ - "deepfreeze-core>=1.0.0", + "elastic-deepfreeze-core>=1.0.0", "click>=8.0.0", "voluptuous>=0.14.0", "pyyaml>=6.0.0", @@ -53,19 +54,19 @@ dev = [ ] [project.scripts] -deepfreeze = "deepfreeze.cli.main:cli" +deepfreeze = "elastic_deepfreeze.cli.main:cli" [project.urls] Homepage = "https://github.com/elastic/deepfreeze" -Documentation = "https://github.com/elastic/deepfreeze/tree/main/packages/deepfreeze-cli" +Documentation = "https://github.com/elastic/deepfreeze/tree/main/packages/elastic-deepfreeze-cli" Repository = "https://github.com/elastic/deepfreeze" [tool.hatch.build.targets.wheel] -packages = ["deepfreeze"] +packages = ["elastic_deepfreeze"] [tool.hatch.build.targets.sdist] include = [ - "deepfreeze/**/*.py", + "elastic_deepfreeze/**/*.py", "README.md", "pyproject.toml", "config.yml.example", diff --git a/packages/deepfreeze-core/README.md b/packages/elastic-deepfreeze-core/README.md similarity index 72% rename from packages/deepfreeze-core/README.md rename to packages/elastic-deepfreeze-core/README.md index fa171cc..0d0a18c 100644 --- a/packages/deepfreeze-core/README.md +++ b/packages/elastic-deepfreeze-core/README.md @@ -1,17 +1,22 @@ -# Deepfreeze Core +# Elastic Deepfreeze Core Core library for Elasticsearch S3 Glacier archival operations. ## Overview This package provides the shared functionality for deepfreeze operations, used by both: -- **deepfreeze-cli**: Standalone CLI tool +- **elastic-deepfreeze-cli**: Standalone CLI tool - **elasticsearch-curator**: Full Curator with deepfreeze support ## Installation ```bash -pip install deepfreeze-core +pip install elastic-deepfreeze-core +``` + +Or from source: +```bash +pip install git+https://github.com/elastic/deepfreeze.git#subdirectory=packages/elastic-deepfreeze-core ``` ## Usage @@ -19,7 +24,7 @@ pip install deepfreeze-core This package is typically used as a dependency by other packages. For direct usage: ```python -from deepfreeze_core import ( +from elastic_deepfreeze_core import ( Setup, Status, Rotate, Thaw, Refreeze, Cleanup, RepairMetadata, s3_client_factory, create_es_client ) @@ -58,6 +63,10 @@ pip install -e ".[dev]" pytest # Format code -black deepfreeze_core/ -ruff check deepfreeze_core/ +black elastic_deepfreeze_core/ +ruff check elastic_deepfreeze_core/ ``` + +## Why "elastic-deepfreeze-core"? + +The package name includes the `elastic-` prefix to prevent dependency confusion attacks. See the [main README](../../README.md) for details. diff --git a/packages/deepfreeze-core/deepfreeze_core/__init__.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/__init__.py similarity index 89% rename from packages/deepfreeze-core/deepfreeze_core/__init__.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/__init__.py index 38d63ac..77684c0 100644 --- a/packages/deepfreeze-core/deepfreeze_core/__init__.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/__init__.py @@ -9,7 +9,7 @@ # Export constants # Export actions -from deepfreeze_core.actions import ( +from elastic_deepfreeze_core.actions import ( Cleanup, Refreeze, RepairMetadata, @@ -18,7 +18,7 @@ Status, Thaw, ) -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( PROVIDERS, SETTINGS_ID, STATUS_INDEX, @@ -29,7 +29,7 @@ ) # Export ES client utilities -from deepfreeze_core.esclient import ( +from elastic_deepfreeze_core.esclient import ( ESClientWrapper, create_es_client, create_es_client_from_config, @@ -38,7 +38,7 @@ ) # Export exceptions -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.exceptions import ( ActionError, ActionException, DeepfreezeException, @@ -49,21 +49,21 @@ ) # Export helpers -from deepfreeze_core.helpers import ( +from elastic_deepfreeze_core.helpers import ( Deepfreeze, Repository, Settings, ) # Export S3 client -from deepfreeze_core.s3client import ( +from elastic_deepfreeze_core.s3client import ( AwsS3Client, S3Client, s3_client_factory, ) # Export commonly used utilities -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.utilities import ( check_restore_status, create_repo, decode_date, diff --git a/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/__init__.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/__init__.py new file mode 100644 index 0000000..0e14347 --- /dev/null +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/__init__.py @@ -0,0 +1,24 @@ +"""Deepfreeze action modules + +This module exports all action classes for the standalone deepfreeze package. +Each action class provides do_action() and do_dry_run() methods for performing +deepfreeze operations. +""" + +from elastic_deepfreeze_core.actions.cleanup import Cleanup +from elastic_deepfreeze_core.actions.refreeze import Refreeze +from elastic_deepfreeze_core.actions.repair_metadata import RepairMetadata +from elastic_deepfreeze_core.actions.rotate import Rotate +from elastic_deepfreeze_core.actions.setup import Setup +from elastic_deepfreeze_core.actions.status import Status +from elastic_deepfreeze_core.actions.thaw import Thaw + +__all__ = [ + "Setup", + "Status", + "Rotate", + "Thaw", + "Refreeze", + "Cleanup", + "RepairMetadata", +] diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/cleanup.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/cleanup.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/cleanup.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/cleanup.py index f9465e6..38c7f31 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/cleanup.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/cleanup.py @@ -11,19 +11,19 @@ from rich.panel import Panel from rich.table import Table -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( STATUS_INDEX, THAW_STATE_EXPIRED, THAW_STATUS_COMPLETED, THAW_STATUS_FAILED, THAW_STATUS_REFROZEN, ) -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.exceptions import ( MissingIndexError, MissingSettingsError, ) -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( get_matching_repos, get_settings, is_policy_safe_to_delete, @@ -44,7 +44,7 @@ class Cleanup: do_action: Perform the cleanup operation :example: - >>> from deepfreeze_core.actions import Cleanup + >>> from elastic_deepfreeze_core.actions import Cleanup >>> cleanup = Cleanup(client) >>> cleanup.do_action() """ diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/refreeze.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/refreeze.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/refreeze.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/refreeze.py index ccedfff..7d15a87 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/refreeze.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/refreeze.py @@ -10,19 +10,19 @@ from rich.panel import Panel from rich.table import Table -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( STATUS_INDEX, THAW_STATUS_COMPLETED, THAW_STATUS_REFROZEN, ) -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.exceptions import ( ActionError, MissingIndexError, MissingSettingsError, ) -from deepfreeze_core.helpers import Repository -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.helpers import Repository +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( get_all_indices_in_repo, get_repositories_by_names, get_settings, @@ -50,7 +50,7 @@ class Refreeze: do_action: Perform the refreeze operation :example: - >>> from deepfreeze_core.actions import Refreeze + >>> from elastic_deepfreeze_core.actions import Refreeze >>> refreeze = Refreeze(client, request_id="abc12345") >>> refreeze.do_action() """ diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/repair_metadata.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/repair_metadata.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/repair_metadata.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/repair_metadata.py index 3241d18..e12d881 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/repair_metadata.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/repair_metadata.py @@ -10,16 +10,16 @@ from rich.panel import Panel from rich.table import Table -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( STATUS_INDEX, THAW_STATE_ACTIVE, THAW_STATE_FROZEN, THAW_STATE_THAWED, THAW_STATE_THAWING, ) -from deepfreeze_core.exceptions import MissingIndexError, MissingSettingsError -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.exceptions import MissingIndexError, MissingSettingsError +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( get_all_repos, get_settings, ) @@ -42,7 +42,7 @@ class RepairMetadata: do_action: Scan and repair discrepancies :example: - >>> from deepfreeze_core.actions import RepairMetadata + >>> from elastic_deepfreeze_core.actions import RepairMetadata >>> repair = RepairMetadata(client) >>> repair.do_action() """ @@ -250,7 +250,7 @@ def _repair_discrepancy(self, discrepancy: dict, dry_run: bool = False) -> dict: try: # Get the repo from status index and update - from deepfreeze_core.helpers import Repository + from elastic_deepfreeze_core.helpers import Repository repo = Repository.from_elasticsearch( self.client, discrepancy["repo"], STATUS_INDEX diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/rotate.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/rotate.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/rotate.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/rotate.py index 5017abc..2576d53 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/rotate.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/rotate.py @@ -9,14 +9,14 @@ from rich.markup import escape from rich.panel import Panel -from deepfreeze_core.constants import STATUS_INDEX, THAW_STATE_FROZEN -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.constants import STATUS_INDEX, THAW_STATE_FROZEN +from elastic_deepfreeze_core.exceptions import ( MissingIndexError, MissingSettingsError, ) -from deepfreeze_core.helpers import Settings -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.helpers import Settings +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( create_repo, create_versioned_ilm_policy, get_composable_templates, @@ -47,7 +47,7 @@ class Rotate: do_action: Perform the rotation :example: - >>> from deepfreeze_core.actions import Rotate + >>> from elastic_deepfreeze_core.actions import Rotate >>> rotate = Rotate(client, keep=2) >>> rotate.do_action() """ diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/setup.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/setup.py similarity index 99% rename from packages/deepfreeze-core/deepfreeze_core/actions/setup.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/setup.py index a8d2e25..8823cc4 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/setup.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/setup.py @@ -9,11 +9,11 @@ from rich.markup import escape from rich.panel import Panel -from deepfreeze_core.constants import STATUS_INDEX -from deepfreeze_core.exceptions import PreconditionError -from deepfreeze_core.helpers import Settings -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.constants import STATUS_INDEX +from elastic_deepfreeze_core.exceptions import PreconditionError +from elastic_deepfreeze_core.helpers import Settings +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( create_or_update_ilm_policy, create_repo, ensure_settings_index, @@ -53,7 +53,7 @@ class Setup: do_action: Perform create initial bucket and repository. :example: - >>> from deepfreeze_core.actions import Setup + >>> from elastic_deepfreeze_core.actions import Setup >>> setup = Setup(client, repo_name_prefix="deepfreeze", bucket_name_prefix="deepfreeze", ... base_path_prefix="snapshots", canned_acl="private", ... storage_class="intelligent_tiering", provider="aws", rotate_by="path", diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/status.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/status.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/status.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/status.py index edb38b2..60e097c 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/status.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/status.py @@ -10,14 +10,14 @@ from rich.panel import Panel from rich.table import Table -from deepfreeze_core.constants import STATUS_INDEX -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.constants import STATUS_INDEX +from elastic_deepfreeze_core.exceptions import ( ActionError, MissingIndexError, MissingSettingsError, ) -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( get_all_repos, get_matching_repo_names, get_settings, @@ -38,7 +38,7 @@ class Status: do_action: Display status information :example: - >>> from deepfreeze_core.actions import Status + >>> from elastic_deepfreeze_core.actions import Status >>> status = Status(client) >>> status.do_action() """ diff --git a/packages/deepfreeze-core/deepfreeze_core/actions/thaw.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/thaw.py similarity index 98% rename from packages/deepfreeze-core/deepfreeze_core/actions/thaw.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/thaw.py index 91a7378..6b6f18c 100644 --- a/packages/deepfreeze-core/deepfreeze_core/actions/thaw.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/actions/thaw.py @@ -14,19 +14,19 @@ from rich.progress import Progress, SpinnerColumn, TextColumn from rich.table import Table -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( STATUS_INDEX, THAW_STATUS_COMPLETED, THAW_STATUS_FAILED, THAW_STATUS_IN_PROGRESS, ) -from deepfreeze_core.exceptions import ( +from elastic_deepfreeze_core.exceptions import ( ActionError, MissingIndexError, MissingSettingsError, ) -from deepfreeze_core.s3client import s3_client_factory -from deepfreeze_core.utilities import ( +from elastic_deepfreeze_core.s3client import s3_client_factory +from elastic_deepfreeze_core.utilities import ( check_restore_status, decode_date, find_and_mount_indices_in_date_range, @@ -64,7 +64,7 @@ class Thaw: do_action: Perform the thaw operation :example: - >>> from deepfreeze_core.actions import Thaw + >>> from elastic_deepfreeze_core.actions import Thaw >>> thaw = Thaw(client, start_date=datetime(2023, 1, 1), end_date=datetime(2023, 1, 31)) >>> thaw.do_action() """ diff --git a/packages/deepfreeze-core/deepfreeze_core/constants.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/constants.py similarity index 100% rename from packages/deepfreeze-core/deepfreeze_core/constants.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/constants.py diff --git a/packages/deepfreeze-core/deepfreeze_core/esclient.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/esclient.py similarity index 99% rename from packages/deepfreeze-core/deepfreeze_core/esclient.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/esclient.py index 63ba9b7..8d62541 100644 --- a/packages/deepfreeze-core/deepfreeze_core/esclient.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/esclient.py @@ -12,7 +12,7 @@ from elasticsearch8.exceptions import AuthenticationException from elasticsearch8.exceptions import ConnectionError as ESConnectionError -from deepfreeze_core.exceptions import ActionError +from elastic_deepfreeze_core.exceptions import ActionError def create_es_client( diff --git a/packages/deepfreeze-core/deepfreeze_core/exceptions.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/exceptions.py similarity index 100% rename from packages/deepfreeze-core/deepfreeze_core/exceptions.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/exceptions.py diff --git a/packages/deepfreeze-core/deepfreeze_core/helpers.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/helpers.py similarity index 99% rename from packages/deepfreeze-core/deepfreeze_core/helpers.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/helpers.py index 1f81f17..8e2feff 100644 --- a/packages/deepfreeze-core/deepfreeze_core/helpers.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/helpers.py @@ -14,7 +14,7 @@ from elasticsearch8 import Elasticsearch -from deepfreeze_core.constants import ( +from elastic_deepfreeze_core.constants import ( STATUS_INDEX, THAW_STATE_ACTIVE, THAW_STATE_EXPIRED, diff --git a/packages/deepfreeze-core/deepfreeze_core/s3client.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/s3client.py similarity index 99% rename from packages/deepfreeze-core/deepfreeze_core/s3client.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/s3client.py index d8a55d2..645657d 100644 --- a/packages/deepfreeze-core/deepfreeze_core/s3client.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/s3client.py @@ -11,7 +11,7 @@ import boto3 from botocore.exceptions import ClientError -from deepfreeze_core.exceptions import ActionError +from elastic_deepfreeze_core.exceptions import ActionError class S3Client(metaclass=abc.ABCMeta): @@ -68,7 +68,7 @@ def thaw( retrieval_tier: str = "Standard", ) -> None: """ - Return a bucket from deepfreeze_core. + Return a bucket from elastic_deepfreeze_core. Args: bucket_name (str): The name of the bucket to return. diff --git a/packages/deepfreeze-core/deepfreeze_core/utilities.py b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/utilities.py similarity index 99% rename from packages/deepfreeze-core/deepfreeze_core/utilities.py rename to packages/elastic-deepfreeze-core/elastic_deepfreeze_core/utilities.py index 2fc28cc..dcabb51 100644 --- a/packages/deepfreeze-core/deepfreeze_core/utilities.py +++ b/packages/elastic-deepfreeze-core/elastic_deepfreeze_core/utilities.py @@ -18,10 +18,10 @@ import botocore from elasticsearch8 import Elasticsearch, NotFoundError -from deepfreeze_core.constants import SETTINGS_ID, STATUS_INDEX -from deepfreeze_core.exceptions import ActionError, MissingIndexError -from deepfreeze_core.helpers import Repository, Settings -from deepfreeze_core.s3client import S3Client +from elastic_deepfreeze_core.constants import SETTINGS_ID, STATUS_INDEX +from elastic_deepfreeze_core.exceptions import ActionError, MissingIndexError +from elastic_deepfreeze_core.helpers import Repository, Settings +from elastic_deepfreeze_core.s3client import S3Client def push_to_glacier(s3: S3Client, repo: Repository) -> bool: diff --git a/packages/deepfreeze-core/pyproject.toml b/packages/elastic-deepfreeze-core/pyproject.toml similarity index 92% rename from packages/deepfreeze-core/pyproject.toml rename to packages/elastic-deepfreeze-core/pyproject.toml index 687de5c..0ee42a1 100644 --- a/packages/deepfreeze-core/pyproject.toml +++ b/packages/elastic-deepfreeze-core/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "deepfreeze-core" +name = "elastic-deepfreeze-core" version = "1.0.0" description = "Core library for Elasticsearch S3 Glacier archival - shared between curator and standalone deepfreeze" readme = "README.md" @@ -14,6 +14,7 @@ authors = [ ] keywords = [ "elasticsearch", + "elastic", "glacier", "s3", "archival", @@ -53,15 +54,15 @@ dev = [ [project.urls] Homepage = "https://github.com/elastic/deepfreeze" -Documentation = "https://github.com/elastic/deepfreeze/tree/main/packages/deepfreeze-core" +Documentation = "https://github.com/elastic/deepfreeze/tree/main/packages/elastic-deepfreeze-core" Repository = "https://github.com/elastic/deepfreeze" [tool.hatch.build.targets.wheel] -packages = ["deepfreeze_core"] +packages = ["elastic_deepfreeze_core"] [tool.hatch.build.targets.sdist] include = [ - "deepfreeze_core/**/*.py", + "elastic_deepfreeze_core/**/*.py", "README.md", "pyproject.toml", ] @@ -73,8 +74,6 @@ target-version = ["py38", "py39", "py310", "py311", "py312"] [tool.ruff] line-length = 88 target-version = "py38" - -[tool.ruff.lint] select = ["E", "F", "W", "I", "UP", "B", "C4"] ignore = ["E501"] diff --git a/pyproject.toml b/pyproject.toml index 5938498..f0c34d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,14 +12,14 @@ requires-python = ">=3.8" [tool.hatch.envs.default] dependencies = [ - "packages/deepfreeze-core", - "packages/deepfreeze-cli", + "packages/elastic-deepfreeze-core", + "packages/elastic-deepfreeze-cli", ] [tool.hatch.envs.test] dependencies = [ - "packages/deepfreeze-core", - "packages/deepfreeze-cli", + "packages/elastic-deepfreeze-core", + "packages/elastic-deepfreeze-cli", "pytest>=7.0.0", "pytest-cov>=4.0.0", "moto[s3]>=4.0.0", @@ -29,7 +29,7 @@ dependencies = [ all = "pytest tests/ -v" core = "pytest tests/core/ -v" cli = "pytest tests/cli/ -v" -cov = "pytest tests/ --cov=deepfreeze_core --cov=deepfreeze --cov-report=term-missing" +cov = "pytest tests/ --cov=elastic_deepfreeze_core --cov=elastic_deepfreeze --cov-report=term-missing" [tool.black] line-length = 88 @@ -38,7 +38,5 @@ target-version = ["py38", "py39", "py310", "py311", "py312"] [tool.ruff] line-length = 88 target-version = "py38" - -[tool.ruff.lint] select = ["E", "F", "W", "I", "UP", "B", "C4"] ignore = ["E501"] diff --git a/tests/cli/test_actions.py b/tests/cli/test_actions.py index 281c46f..218d5e6 100644 --- a/tests/cli/test_actions.py +++ b/tests/cli/test_actions.py @@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch import pytest -from deepfreeze import ( +from elastic_deepfreeze import ( Cleanup, MissingIndexError, MissingSettingsError, @@ -28,7 +28,7 @@ def test_setup_initialization(self): mock_client = MagicMock() # Mock s3_client_factory - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 @@ -52,7 +52,7 @@ def test_setup_preconditions_fail_status_index_exists(self): mock_client.indices.exists.return_value = True mock_client.snapshot.get_repository.return_value = {} - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_s3.bucket_exists.return_value = False mock_factory.return_value = mock_s3 @@ -83,12 +83,12 @@ def test_setup_dry_run(self): # Mock cluster info to return ES 8.x (no S3 plugin check needed) mock_client.info.return_value = {"version": {"number": "8.10.0"}} - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_s3.bucket_exists.return_value = False mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.setup.create_repo") as mock_create: + with patch("elastic_deepfreeze_core.actions.setup.create_repo") as mock_create: setup = Setup( client=mock_client, repo_name_prefix="test-repo", @@ -115,23 +115,23 @@ def test_setup_do_action_success(self): } mock_client.info.return_value = {"version": {"number": "8.10.0"}} - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_s3.bucket_exists.return_value = False mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.setup.ensure_settings_index"): - with patch("deepfreeze_core.actions.setup.save_settings"): - with patch("deepfreeze_core.actions.setup.create_repo"): + with patch("elastic_deepfreeze_core.actions.setup.ensure_settings_index"): + with patch("elastic_deepfreeze_core.actions.setup.save_settings"): + with patch("elastic_deepfreeze_core.actions.setup.create_repo"): with patch( - "deepfreeze_core.actions.setup.create_or_update_ilm_policy" + "elastic_deepfreeze_core.actions.setup.create_or_update_ilm_policy" ) as mock_ilm: mock_ilm.return_value = { "action": "created", "policy_body": {}, } with patch( - "deepfreeze_core.actions.setup.update_index_template_ilm_policy" + "elastic_deepfreeze_core.actions.setup.update_index_template_ilm_policy" ) as mock_template: mock_template.return_value = { "action": "updated", @@ -180,7 +180,7 @@ def test_status_raises_missing_settings_error(self): mock_client = MagicMock() mock_client.indices.exists.return_value = True - with patch("deepfreeze_core.actions.status.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.status.get_settings") as mock_get: mock_get.return_value = None status = Status(client=mock_client, porcelain=True) @@ -223,17 +223,17 @@ def test_rotate_dry_run_shows_what_would_happen(self): last_suffix="000001", ) - with patch("deepfreeze_core.actions.rotate.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.rotate.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.rotate.s3_client_factory" + "elastic_deepfreeze_core.actions.rotate.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.rotate.get_matching_repos" + "elastic_deepfreeze_core.actions.rotate.get_matching_repos" ) as mock_repos: mock_repos.return_value = [] @@ -256,17 +256,17 @@ def test_rotate_calculates_next_suffix(self): last_suffix="000005", ) - with patch("deepfreeze_core.actions.rotate.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.rotate.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.rotate.s3_client_factory" + "elastic_deepfreeze_core.actions.rotate.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.rotate.get_matching_repos" + "elastic_deepfreeze_core.actions.rotate.get_matching_repos" ) as mock_repos: mock_repos.return_value = [] @@ -312,17 +312,17 @@ def test_thaw_list_mode(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.thaw.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.thaw.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.thaw.s3_client_factory" + "elastic_deepfreeze_core.actions.thaw.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.thaw.list_thaw_requests" + "elastic_deepfreeze_core.actions.thaw.list_thaw_requests" ) as mock_list: mock_list.return_value = [] @@ -355,17 +355,17 @@ def test_thaw_initiate_finds_repos(self): start = datetime(2023, 1, 1, tzinfo=timezone.utc) end = datetime(2023, 1, 31, tzinfo=timezone.utc) - with patch("deepfreeze_core.actions.thaw.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.thaw.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.thaw.s3_client_factory" + "elastic_deepfreeze_core.actions.thaw.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.thaw.find_repos_by_date_range" + "elastic_deepfreeze_core.actions.thaw.find_repos_by_date_range" ) as mock_find: mock_find.return_value = [] # No repos found @@ -410,17 +410,17 @@ def test_refreeze_all_mode(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.refreeze.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.refreeze.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.refreeze.s3_client_factory" + "elastic_deepfreeze_core.actions.refreeze.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.refreeze.list_thaw_requests" + "elastic_deepfreeze_core.actions.refreeze.list_thaw_requests" ) as mock_list: mock_list.return_value = [] # No completed requests @@ -460,22 +460,22 @@ def test_cleanup_dry_run_finds_expired_repos(self): mock_settings = Settings(repo_name_prefix="deepfreeze") - with patch("deepfreeze_core.actions.cleanup.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.cleanup.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.cleanup.s3_client_factory" + "elastic_deepfreeze_core.actions.cleanup.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.cleanup.get_matching_repos" + "elastic_deepfreeze_core.actions.cleanup.get_matching_repos" ) as mock_repos: mock_repos.return_value = [] with patch( - "deepfreeze_core.actions.cleanup.list_thaw_requests" + "elastic_deepfreeze_core.actions.cleanup.list_thaw_requests" ) as mock_list: mock_list.return_value = [] @@ -498,22 +498,22 @@ def test_cleanup_finds_old_thaw_requests(self): old_date = datetime(2020, 1, 1, tzinfo=timezone.utc).isoformat() - with patch("deepfreeze_core.actions.cleanup.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.cleanup.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.cleanup.s3_client_factory" + "elastic_deepfreeze_core.actions.cleanup.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.cleanup.get_matching_repos" + "elastic_deepfreeze_core.actions.cleanup.get_matching_repos" ) as mock_repos: mock_repos.return_value = [] with patch( - "deepfreeze_core.actions.cleanup.list_thaw_requests" + "elastic_deepfreeze_core.actions.cleanup.list_thaw_requests" ) as mock_list: mock_list.return_value = [ { @@ -558,17 +558,17 @@ def test_repair_metadata_dry_run_scans_repos(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.repair_metadata.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.repair_metadata.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.repair_metadata.s3_client_factory" + "elastic_deepfreeze_core.actions.repair_metadata.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.repair_metadata.get_all_repos" + "elastic_deepfreeze_core.actions.repair_metadata.get_all_repos" ) as mock_repos: mock_repos.return_value = [] @@ -606,13 +606,13 @@ class TestNoCuratorImports: @pytest.mark.parametrize( "module_name", [ - "deepfreeze_core.actions.setup", - "deepfreeze_core.actions.status", - "deepfreeze_core.actions.rotate", - "deepfreeze_core.actions.thaw", - "deepfreeze_core.actions.refreeze", - "deepfreeze_core.actions.cleanup", - "deepfreeze_core.actions.repair_metadata", + "elastic_deepfreeze_core.actions.setup", + "elastic_deepfreeze_core.actions.status", + "elastic_deepfreeze_core.actions.rotate", + "elastic_deepfreeze_core.actions.thaw", + "elastic_deepfreeze_core.actions.refreeze", + "elastic_deepfreeze_core.actions.cleanup", + "elastic_deepfreeze_core.actions.repair_metadata", ], ) def test_no_curator_imports(self, module_name): @@ -640,7 +640,7 @@ def test_setup_with_custom_storage_class(self): """Test Setup with custom storage class""" mock_client = MagicMock() - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 @@ -659,7 +659,7 @@ def test_setup_with_canned_acl(self): """Test Setup with canned ACL option""" mock_client = MagicMock() - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 @@ -688,23 +688,23 @@ def test_status_porcelain_mode(self): bucket_name_prefix="deepfreeze", ) - with patch("deepfreeze_core.actions.status.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.status.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.status.s3_client_factory" + "elastic_deepfreeze_core.actions.status.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_s3.list_buckets.return_value = [] mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.status.get_all_repos" + "elastic_deepfreeze_core.actions.status.get_all_repos" ) as mock_repos: mock_repos.return_value = [] with patch( - "deepfreeze_core.actions.status.list_thaw_requests" + "elastic_deepfreeze_core.actions.status.list_thaw_requests" ) as mock_thaw: mock_thaw.return_value = [] @@ -723,23 +723,23 @@ def test_status_with_porcelain_false(self): bucket_name_prefix="deepfreeze", ) - with patch("deepfreeze_core.actions.status.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.status.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.status.s3_client_factory" + "elastic_deepfreeze_core.actions.status.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_s3.list_buckets.return_value = [] mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.status.get_all_repos" + "elastic_deepfreeze_core.actions.status.get_all_repos" ) as mock_repos: mock_repos.return_value = [] with patch( - "deepfreeze_core.actions.status.list_thaw_requests" + "elastic_deepfreeze_core.actions.status.list_thaw_requests" ) as mock_thaw: mock_thaw.return_value = [] @@ -759,16 +759,16 @@ def test_thaw_request_id_mode(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.thaw.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.thaw.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.thaw.s3_client_factory" + "elastic_deepfreeze_core.actions.thaw.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.thaw.get_thaw_request") as mock_req: + with patch("elastic_deepfreeze_core.actions.thaw.get_thaw_request") as mock_req: mock_req.return_value = { "request_id": "test-123", "status": "in_progress", @@ -810,17 +810,17 @@ def test_refreeze_dry_run(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.refreeze.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.refreeze.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.refreeze.s3_client_factory" + "elastic_deepfreeze_core.actions.refreeze.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.refreeze.get_thaw_request" + "elastic_deepfreeze_core.actions.refreeze.get_thaw_request" ) as mock_req: mock_req.return_value = { "request_id": "test-123", @@ -861,17 +861,17 @@ def test_cleanup_dry_run_shows_what_would_be_cleaned(self): old_date = datetime(2020, 1, 1, tzinfo=timezone.utc).isoformat() - with patch("deepfreeze_core.actions.cleanup.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.cleanup.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.cleanup.s3_client_factory" + "elastic_deepfreeze_core.actions.cleanup.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.cleanup.get_matching_repos" + "elastic_deepfreeze_core.actions.cleanup.get_matching_repos" ) as mock_repos: # Expired repository expired_repo = Repository( @@ -882,7 +882,7 @@ def test_cleanup_dry_run_shows_what_would_be_cleaned(self): mock_repos.return_value = [expired_repo] with patch( - "deepfreeze_core.actions.cleanup.list_thaw_requests" + "elastic_deepfreeze_core.actions.cleanup.list_thaw_requests" ) as mock_list: mock_list.return_value = [ { @@ -909,17 +909,17 @@ def test_repair_metadata_porcelain_output(self): mock_settings = Settings() - with patch("deepfreeze_core.actions.repair_metadata.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.repair_metadata.get_settings") as mock_get: mock_get.return_value = mock_settings with patch( - "deepfreeze_core.actions.repair_metadata.s3_client_factory" + "elastic_deepfreeze_core.actions.repair_metadata.s3_client_factory" ) as mock_factory: mock_s3 = MagicMock() mock_factory.return_value = mock_s3 with patch( - "deepfreeze_core.actions.repair_metadata.get_all_repos" + "elastic_deepfreeze_core.actions.repair_metadata.get_all_repos" ) as mock_repos: mock_repos.return_value = [] diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 59ee38b..9569ce2 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -6,7 +6,7 @@ import pytest from click.testing import CliRunner -from deepfreeze.cli.main import cli +from elastic_deepfreeze.cli.main import cli @pytest.fixture @@ -81,7 +81,7 @@ class TestCLIOptionParsing: def test_setup_requires_ilm_policy(self, runner, temp_config_file): """Test that setup requires --ilm_policy_name.""" - with patch("deepfreeze.cli.main.get_client_from_context"): + with patch("elastic_deepfreeze.cli.main.get_client_from_context"): result = runner.invoke( cli, [ @@ -98,7 +98,7 @@ def test_setup_requires_ilm_policy(self, runner, temp_config_file): def test_setup_requires_index_template(self, runner, temp_config_file): """Test that setup requires --index_template_name.""" - with patch("deepfreeze.cli.main.get_client_from_context"): + with patch("elastic_deepfreeze.cli.main.get_client_from_context"): result = runner.invoke( cli, ["-c", temp_config_file, "setup", "--ilm_policy_name", "test-policy"], @@ -109,14 +109,14 @@ def test_setup_requires_index_template(self, runner, temp_config_file): def test_thaw_requires_mode(self, runner, temp_config_file): """Test that thaw requires one of the operation modes.""" - with patch("deepfreeze.cli.main.get_client_from_context"): + with patch("elastic_deepfreeze.cli.main.get_client_from_context"): result = runner.invoke(cli, ["-c", temp_config_file, "thaw"]) assert result.exit_code != 0 assert "Must specify one of" in result.output def test_thaw_date_range_requires_both_dates(self, runner, temp_config_file): """Test that thaw with date range requires both start and end dates.""" - with patch("deepfreeze.cli.main.get_client_from_context"): + with patch("elastic_deepfreeze.cli.main.get_client_from_context"): result = runner.invoke( cli, [ @@ -134,7 +134,7 @@ def test_thaw_date_range_requires_both_dates(self, runner, temp_config_file): class TestCLIWithMockedClient: """Test CLI commands with mocked Elasticsearch client.""" - @patch("deepfreeze.cli.main.create_es_client") + @patch("elastic_deepfreeze.cli.main.create_es_client") def test_dry_run_flag_parsed(self, mock_create_client, runner, temp_config_file): """Test that --dry-run flag is parsed correctly.""" mock_client = MagicMock() @@ -143,7 +143,7 @@ def test_dry_run_flag_parsed(self, mock_create_client, runner, temp_config_file) # We need to mock the entire chain to avoid errors mock_client.indices.exists.return_value = False - with patch("deepfreeze_core.actions.setup.Setup") as mock_setup_class: + with patch("elastic_deepfreeze_core.actions.setup.Setup") as mock_setup_class: mock_setup = MagicMock() mock_setup_class.return_value = mock_setup @@ -218,9 +218,9 @@ def test_default_config_path_in_help(self, runner): def test_get_default_config_file_not_exists(self): """Test that get_default_config_file returns None when file doesn't exist.""" - from deepfreeze.cli.main import get_default_config_file + from elastic_deepfreeze.cli.main import get_default_config_file - with patch("deepfreeze.cli.main.DEFAULT_CONFIG_PATH") as mock_path: + with patch("elastic_deepfreeze.cli.main.DEFAULT_CONFIG_PATH") as mock_path: mock_path.is_file.return_value = False result = get_default_config_file() assert result is None @@ -228,13 +228,13 @@ def test_get_default_config_file_not_exists(self): def test_get_default_config_file_exists(self, tmp_path): """Test that get_default_config_file returns path when file exists.""" - from deepfreeze.cli.main import get_default_config_file + from elastic_deepfreeze.cli.main import get_default_config_file # Create a temporary config file config_file = tmp_path / "config.yml" config_file.write_text("elasticsearch:\n hosts:\n - localhost:9200\n") - with patch("deepfreeze.cli.main.DEFAULT_CONFIG_PATH", config_file): + with patch("elastic_deepfreeze.cli.main.DEFAULT_CONFIG_PATH", config_file): result = get_default_config_file() assert result == str(config_file) @@ -252,9 +252,9 @@ def test_cli_uses_default_config_when_exists(self, runner, tmp_path): """ config_file.write_text(config_content) - with patch("deepfreeze.cli.main.DEFAULT_CONFIG_PATH", config_file): + with patch("elastic_deepfreeze.cli.main.DEFAULT_CONFIG_PATH", config_file): with patch( - "deepfreeze.cli.main.get_default_config_file", + "elastic_deepfreeze.cli.main.get_default_config_file", return_value=str(config_file), ): result = runner.invoke(cli, ["--help"]) diff --git a/tests/cli/test_config.py b/tests/cli/test_config.py index 1273608..999db75 100644 --- a/tests/cli/test_config.py +++ b/tests/cli/test_config.py @@ -5,8 +5,8 @@ from unittest.mock import patch import pytest -from deepfreeze import ActionError -from deepfreeze.config import ( +from elastic_deepfreeze import ActionError +from elastic_deepfreeze.config import ( get_elasticsearch_config, get_logging_config, load_config, diff --git a/tests/cli/test_esclient.py b/tests/cli/test_esclient.py index 2fed505..d4f128c 100644 --- a/tests/cli/test_esclient.py +++ b/tests/cli/test_esclient.py @@ -19,10 +19,10 @@ class TestCreateEsClient: """Tests for create_es_client function""" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_create_with_username_password(self, mock_es_class): """Test creating client with username/password authentication""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client # Mock successful connection mock_client = MagicMock() @@ -45,10 +45,10 @@ def test_create_with_username_password(self, mock_es_class): assert call_kwargs["basic_auth"] == ("elastic", "changeme") mock_client.cluster.health.assert_called_once() - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_create_with_api_key(self, mock_es_class): """Test creating client with API key authentication""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -66,10 +66,10 @@ def test_create_with_api_key(self, mock_es_class): call_kwargs = mock_es_class.call_args[1] assert call_kwargs["api_key"] == "base64-encoded-key" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_create_with_cloud_id(self, mock_es_class): """Test creating client with Elastic Cloud ID""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -87,10 +87,10 @@ def test_create_with_cloud_id(self, mock_es_class): call_kwargs = mock_es_class.call_args[1] assert call_kwargs["cloud_id"] == "deployment:base64string" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_create_with_certificates(self, mock_es_class): """Test creating client with SSL certificates""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -114,7 +114,7 @@ def test_create_with_certificates(self, mock_es_class): def test_create_missing_hosts_and_cloud_id(self): """Test that ValueError is raised when neither hosts nor cloud_id provided""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client with pytest.raises(ValueError) as exc_info: create_es_client(username="user", password="pass") @@ -125,10 +125,10 @@ def test_create_missing_hosts_and_cloud_id(self): class TestConnectionValidation: """Tests for connection validation""" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_connection_validation_success(self, mock_es_class): """Test that connection validation calls cluster health""" - from deepfreeze import create_es_client + from elastic_deepfreeze import create_es_client mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -145,10 +145,10 @@ def test_connection_validation_success(self, mock_es_class): mock_client.cluster.health.assert_called_with(timeout="5s") - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_authentication_failure(self, mock_es_class): """Test that authentication failure raises ActionError""" - from deepfreeze import ActionError, create_es_client + from elastic_deepfreeze import ActionError, create_es_client # Create a mock AuthenticationException that behaves properly mock_auth_exception = MagicMock() @@ -176,10 +176,10 @@ class MockAuthException(Exception): password="credentials", ) - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_generic_exception_raises_action_error(self, mock_es_class): """Test that generic exceptions are converted to ActionError""" - from deepfreeze import ActionError, create_es_client + from elastic_deepfreeze import ActionError, create_es_client mock_client = MagicMock() mock_client.cluster.health.side_effect = Exception("Something went wrong") @@ -198,7 +198,7 @@ class TestYamlConfigLoading: def test_load_config_from_yaml(self): """Test loading configuration from YAML file""" - from deepfreeze import load_config_from_yaml + from elastic_deepfreeze import load_config_from_yaml yaml_content = """ elasticsearch: @@ -231,7 +231,7 @@ def test_load_config_from_yaml(self): def test_load_config_file_not_found(self): """Test that missing file raises ActionError""" - from deepfreeze import ActionError, load_config_from_yaml + from elastic_deepfreeze import ActionError, load_config_from_yaml with pytest.raises(ActionError) as exc_info: load_config_from_yaml("/nonexistent/path/config.yml") @@ -240,7 +240,7 @@ def test_load_config_file_not_found(self): def test_load_config_invalid_yaml(self): """Test that invalid YAML raises ActionError""" - from deepfreeze import ActionError, load_config_from_yaml + from elastic_deepfreeze import ActionError, load_config_from_yaml with tempfile.NamedTemporaryFile(mode="w", suffix=".yml", delete=False) as f: f.write("invalid: yaml: content: [") @@ -254,10 +254,10 @@ def test_load_config_invalid_yaml(self): finally: os.unlink(config_path) - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_create_client_from_config(self, mock_es_class): """Test creating client directly from config file""" - from deepfreeze import create_es_client_from_config + from elastic_deepfreeze import create_es_client_from_config mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -293,7 +293,7 @@ class TestValidateConnection: def test_validate_connection_returns_cluster_info(self): """Test that validate_connection returns cluster information""" - from deepfreeze import validate_connection + from elastic_deepfreeze import validate_connection mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -316,10 +316,10 @@ def test_validate_connection_returns_cluster_info(self): class TestESClientWrapper: """Tests for ESClientWrapper class""" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_wrapper_init_with_params(self, mock_es_class): """Test ESClientWrapper initialization with direct parameters""" - from deepfreeze import ESClientWrapper + from elastic_deepfreeze import ESClientWrapper mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -343,10 +343,10 @@ def test_wrapper_init_with_params(self, mock_es_class): assert wrapper.cluster_status == "green" assert wrapper.version == "8.11.0" - @patch("deepfreeze_core.esclient.Elasticsearch") + @patch("elastic_deepfreeze_core.esclient.Elasticsearch") def test_wrapper_is_healthy(self, mock_es_class): """Test ESClientWrapper.is_healthy() method""" - from deepfreeze import ESClientWrapper + from elastic_deepfreeze import ESClientWrapper mock_client = MagicMock() mock_client.cluster.health.return_value = { @@ -367,7 +367,7 @@ def test_wrapper_is_healthy(self, mock_es_class): def test_wrapper_requires_config_or_params(self): """Test that ESClientWrapper raises error without config or params""" - from deepfreeze import ESClientWrapper + from elastic_deepfreeze import ESClientWrapper with pytest.raises(ValueError) as exc_info: ESClientWrapper() diff --git a/tests/cli/test_exceptions_constants.py b/tests/cli/test_exceptions_constants.py index 52e1522..a73bdba 100644 --- a/tests/cli/test_exceptions_constants.py +++ b/tests/cli/test_exceptions_constants.py @@ -12,8 +12,8 @@ def test_exception_classes_importable(): - """Test that all exception classes can be imported from deepfreeze.exceptions""" - from deepfreeze import ( + """Test that all exception classes can be imported from elastic_deepfreeze.exceptions""" + from elastic_deepfreeze import ( ActionError, ActionException, DeepfreezeException, @@ -35,7 +35,7 @@ def test_exception_classes_importable(): def test_exception_instantiation(): """Test that exception classes can be instantiated with messages""" - from deepfreeze import ( + from elastic_deepfreeze import ( ActionError, DeepfreezeException, MissingIndexError, @@ -59,8 +59,8 @@ def test_exception_instantiation(): def test_constants_importable(): - """Test that all constants can be imported from deepfreeze.constants""" - from deepfreeze_core.constants import ( + """Test that all constants can be imported from elastic_deepfreeze.constants""" + from elastic_deepfreeze_core.constants import ( PROVIDERS, SETTINGS_ID, STATUS_INDEX, @@ -100,9 +100,9 @@ def test_constants_importable(): def test_no_curator_imports_in_exceptions_module(): """Test that no curator imports exist in exceptions.py""" - import deepfreeze_core + import elastic_deepfreeze_core - exceptions_file = Path(deepfreeze_core.__file__).parent / "exceptions.py" + exceptions_file = Path(elastic_deepfreeze_core.__file__).parent / "exceptions.py" with open(exceptions_file) as f: tree = ast.parse(f.read()) @@ -122,9 +122,9 @@ def test_no_curator_imports_in_exceptions_module(): def test_no_curator_imports_in_constants_module(): """Test that no curator imports exist in constants.py""" - import deepfreeze_core + import elastic_deepfreeze_core - constants_file = Path(deepfreeze_core.__file__).parent / "constants.py" + constants_file = Path(elastic_deepfreeze_core.__file__).parent / "constants.py" with open(constants_file) as f: tree = ast.parse(f.read()) diff --git a/tests/cli/test_helpers.py b/tests/cli/test_helpers.py index 0bd4a89..c8ecd0b 100644 --- a/tests/cli/test_helpers.py +++ b/tests/cli/test_helpers.py @@ -19,7 +19,7 @@ class TestRepositorySerialization: def test_repository_to_dict(self): """Test Repository.to_dict() converts all fields correctly""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository start_dt = datetime(2023, 1, 1, 0, 0, 0, tzinfo=timezone.utc) end_dt = datetime(2023, 12, 31, 23, 59, 59, tzinfo=timezone.utc) @@ -47,7 +47,7 @@ def test_repository_to_dict(self): def test_repository_to_json(self): """Test Repository.to_json() returns valid JSON""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository repo = Repository( name="json-test-repo", @@ -64,7 +64,7 @@ def test_repository_to_json(self): def test_repository_from_dict_with_string_dates(self): """Test Repository __post_init__ converts string dates to datetime""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository repo = Repository( name="string-date-repo", @@ -79,7 +79,7 @@ def test_repository_from_dict_with_string_dates(self): def test_repository_comparison(self): """Test Repository.__lt__() for sorting""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository repo_a = Repository(name="deepfreeze-000001") repo_b = Repository(name="deepfreeze-000002") @@ -95,8 +95,8 @@ class TestRepositoryStateTransitions: def test_start_thawing_transition(self): """Test Repository.start_thawing() sets correct state""" - from deepfreeze import Repository - from deepfreeze_core.constants import THAW_STATE_THAWING + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.constants import THAW_STATE_THAWING repo = Repository(name="thaw-test", thaw_state="frozen") expires_at = datetime(2024, 1, 15, tzinfo=timezone.utc) @@ -109,8 +109,8 @@ def test_start_thawing_transition(self): def test_mark_thawed_transition(self): """Test Repository.mark_thawed() sets correct state""" - from deepfreeze import Repository - from deepfreeze_core.constants import THAW_STATE_THAWED + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.constants import THAW_STATE_THAWED repo = Repository(name="mark-thawed-test", thaw_state="thawing") @@ -124,8 +124,8 @@ def test_mark_thawed_transition(self): def test_mark_expired_transition(self): """Test Repository.mark_expired() sets correct state""" - from deepfreeze import Repository - from deepfreeze_core.constants import THAW_STATE_EXPIRED + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.constants import THAW_STATE_EXPIRED repo = Repository(name="expire-test", thaw_state="thawed") repo.thawed_at = datetime(2023, 12, 1, tzinfo=timezone.utc) @@ -138,8 +138,8 @@ def test_mark_expired_transition(self): def test_reset_to_frozen_transition(self): """Test Repository.reset_to_frozen() clears all thaw state""" - from deepfreeze import Repository - from deepfreeze_core.constants import THAW_STATE_FROZEN + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.constants import THAW_STATE_FROZEN repo = Repository( name="reset-test", @@ -160,7 +160,7 @@ def test_reset_to_frozen_transition(self): def test_unmount(self): """Test Repository.unmount() sets is_mounted to False""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository repo = Repository(name="unmount-test", is_mounted=True) @@ -174,7 +174,7 @@ class TestSettingsInitialization: def test_settings_default_values(self): """Test Settings initializes with correct defaults""" - from deepfreeze import Settings + from elastic_deepfreeze import Settings settings = Settings() @@ -193,7 +193,7 @@ def test_settings_default_values(self): def test_settings_custom_values(self): """Test Settings accepts custom initialization values""" - from deepfreeze import Settings + from elastic_deepfreeze import Settings settings = Settings( repo_name_prefix="custom-repo", @@ -211,7 +211,7 @@ def test_settings_custom_values(self): def test_settings_from_hash(self): """Test Settings initializes from settings_hash dict""" - from deepfreeze import Settings + from elastic_deepfreeze import Settings settings_hash = { "repo_name_prefix": "hash-repo", @@ -227,7 +227,7 @@ def test_settings_from_hash(self): def test_settings_to_dict(self): """Test Settings.to_dict() returns all fields""" - from deepfreeze import Settings + from elastic_deepfreeze import Settings settings = Settings(ilm_policy_name="test-policy") result = settings.to_dict() @@ -240,7 +240,7 @@ def test_settings_to_dict(self): def test_settings_to_json(self): """Test Settings.to_json() returns valid JSON""" - from deepfreeze import Settings + from elastic_deepfreeze import Settings settings = Settings() result = settings.to_json() @@ -255,7 +255,7 @@ class TestRepositoryElasticsearchInteraction: def test_from_elasticsearch_success(self): """Test Repository.from_elasticsearch() fetches and creates instance""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository # Mock ES client mock_client = MagicMock() @@ -287,7 +287,7 @@ def test_from_elasticsearch_success(self): def test_from_elasticsearch_not_found(self): """Test Repository.from_elasticsearch() returns None when not found""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository mock_client = MagicMock() mock_client.search.return_value = {"hits": {"hits": []}} @@ -298,7 +298,7 @@ def test_from_elasticsearch_not_found(self): def test_persist_calls_es_update(self): """Test Repository.persist() calls ES update correctly""" - from deepfreeze import Repository + from elastic_deepfreeze import Repository mock_client = MagicMock() repo = Repository( @@ -321,7 +321,7 @@ class TestDeepfreezeClass: def test_deepfreeze_class_exists(self): """Test Deepfreeze class can be instantiated""" - from deepfreeze import Deepfreeze + from elastic_deepfreeze import Deepfreeze df = Deepfreeze() assert df is not None diff --git a/tests/cli/test_independence.py b/tests/cli/test_independence.py index 180d49d..4f864f2 100644 --- a/tests/cli/test_independence.py +++ b/tests/cli/test_independence.py @@ -20,9 +20,9 @@ class TestNoCuratorImports: def test_scan_all_python_files_for_curator_imports(self): """Scan all Python files in deepfreeze package for curator imports using AST""" - import deepfreeze + import elastic_deepfreeze - package_dir = Path(deepfreeze.__file__).parent + package_dir = Path(elastic_deepfreeze.__file__).parent curator_imports = [] for py_file in package_dir.rglob("*.py"): @@ -64,14 +64,14 @@ class TestPackageImportsStandalone: def test_import_deepfreeze(self): """Test that import deepfreeze works""" - import deepfreeze + import elastic_deepfreeze - assert deepfreeze is not None - assert hasattr(deepfreeze, "__version__") + assert elastic_deepfreeze is not None + assert hasattr(elastic_deepfreeze, "__version__") def test_import_deepfreeze_exceptions(self): """Test that exception classes can be imported from deepfreeze""" - from deepfreeze import ( + from elastic_deepfreeze import ( ActionError, DeepfreezeException, ) @@ -80,8 +80,8 @@ def test_import_deepfreeze_exceptions(self): assert issubclass(ActionError, DeepfreezeException) def test_import_deepfreeze_constants(self): - """Test that constants can be imported from deepfreeze_core.constants""" - from deepfreeze_core.constants import ( + """Test that constants can be imported from elastic_deepfreeze_core.constants""" + from elastic_deepfreeze_core.constants import ( PROVIDERS, SETTINGS_ID, STATUS_INDEX, @@ -93,7 +93,7 @@ def test_import_deepfreeze_constants(self): def test_import_deepfreeze_helpers(self): """Test that helper classes can be imported from deepfreeze""" - from deepfreeze import ( + from elastic_deepfreeze import ( Deepfreeze, Repository, Settings, @@ -105,7 +105,7 @@ def test_import_deepfreeze_helpers(self): def test_import_deepfreeze_actions(self): """Test that action classes can be imported from deepfreeze""" - from deepfreeze import ( + from elastic_deepfreeze import ( Cleanup, Refreeze, RepairMetadata, @@ -124,16 +124,16 @@ def test_import_deepfreeze_actions(self): assert RepairMetadata is not None def test_import_deepfreeze_cli(self): - """Test that deepfreeze.cli imports correctly""" + """Test that elastic_deepfreeze.cli imports correctly""" import click - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli assert cli is not None assert isinstance(cli, click.core.Group) def test_import_deepfreeze_validators(self): - """Test that deepfreeze.validators imports correctly""" - from deepfreeze.validators import ( + """Test that elastic_deepfreeze.validators imports correctly""" + from elastic_deepfreeze.validators import ( ACTION_SCHEMAS, get_schema, validate_options, @@ -144,8 +144,8 @@ def test_import_deepfreeze_validators(self): assert get_schema is not None def test_import_deepfreeze_config(self): - """Test that deepfreeze.config imports correctly""" - from deepfreeze.config import ( + """Test that elastic_deepfreeze.config imports correctly""" + from elastic_deepfreeze.config import ( get_elasticsearch_config, get_logging_config, load_config, @@ -162,7 +162,7 @@ class TestCLIFunctionality: def test_cli_help(self): """Test deepfreeze --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["--help"]) @@ -173,7 +173,7 @@ def test_cli_help(self): def test_cli_version(self): """Test deepfreeze --version works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["--version"]) @@ -184,7 +184,7 @@ def test_cli_version(self): def test_cli_setup_help(self): """Test deepfreeze setup --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["setup", "--help"]) @@ -196,7 +196,7 @@ def test_cli_setup_help(self): def test_cli_status_help(self): """Test deepfreeze status --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["status", "--help"]) @@ -207,7 +207,7 @@ def test_cli_status_help(self): def test_cli_rotate_help(self): """Test deepfreeze rotate --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["rotate", "--help"]) @@ -218,7 +218,7 @@ def test_cli_rotate_help(self): def test_cli_thaw_help(self): """Test deepfreeze thaw --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["thaw", "--help"]) @@ -230,7 +230,7 @@ def test_cli_thaw_help(self): def test_cli_refreeze_help(self): """Test deepfreeze refreeze --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["refreeze", "--help"]) @@ -241,7 +241,7 @@ def test_cli_refreeze_help(self): def test_cli_cleanup_help(self): """Test deepfreeze cleanup --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["cleanup", "--help"]) @@ -251,7 +251,7 @@ def test_cli_cleanup_help(self): def test_cli_repair_metadata_help(self): """Test deepfreeze repair-metadata --help works""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["repair-metadata", "--help"]) @@ -262,7 +262,7 @@ def test_cli_repair_metadata_help(self): def test_all_commands_registered(self): """Test that all expected commands are registered""" from click.testing import CliRunner - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli runner = CliRunner() result = runner.invoke(cli, ["--help"]) @@ -287,27 +287,27 @@ class TestModuleIndependence: @pytest.mark.parametrize( "module_name", [ - "deepfreeze", - "deepfreeze.config", - "deepfreeze.cli", - "deepfreeze.cli.main", - "deepfreeze.validators", - "deepfreeze.defaults", - "deepfreeze_core", - "deepfreeze_core.exceptions", - "deepfreeze_core.constants", - "deepfreeze_core.helpers", - "deepfreeze_core.s3client", - "deepfreeze_core.esclient", - "deepfreeze_core.utilities", - "deepfreeze_core.actions", - "deepfreeze_core.actions.setup", - "deepfreeze_core.actions.status", - "deepfreeze_core.actions.rotate", - "deepfreeze_core.actions.thaw", - "deepfreeze_core.actions.refreeze", - "deepfreeze_core.actions.cleanup", - "deepfreeze_core.actions.repair_metadata", + "elastic_deepfreeze", + "elastic_deepfreeze.config", + "elastic_deepfreeze.cli", + "elastic_deepfreeze.cli.main", + "elastic_deepfreeze.validators", + "elastic_deepfreeze.defaults", + "elastic_deepfreeze_core", + "elastic_deepfreeze_core.exceptions", + "elastic_deepfreeze_core.constants", + "elastic_deepfreeze_core.helpers", + "elastic_deepfreeze_core.s3client", + "elastic_deepfreeze_core.esclient", + "elastic_deepfreeze_core.utilities", + "elastic_deepfreeze_core.actions", + "elastic_deepfreeze_core.actions.setup", + "elastic_deepfreeze_core.actions.status", + "elastic_deepfreeze_core.actions.rotate", + "elastic_deepfreeze_core.actions.thaw", + "elastic_deepfreeze_core.actions.refreeze", + "elastic_deepfreeze_core.actions.cleanup", + "elastic_deepfreeze_core.actions.repair_metadata", ], ) def test_module_imports_independently(self, module_name): @@ -326,10 +326,10 @@ def test_pyproject_has_entry_point(self): """Verify pyproject.toml has CLI entry point defined""" from pathlib import Path - import deepfreeze + import elastic_deepfreeze # Find the deepfreeze package's pyproject.toml (in the parent of package dir) - package_dir = Path(deepfreeze.__file__).parent + package_dir = Path(elastic_deepfreeze.__file__).parent # The pyproject.toml should be at the same level as the package # Since __init__.py is at deepfreeze/, pyproject.toml is at deepfreeze/../pyproject.toml @@ -343,21 +343,21 @@ def test_pyproject_has_entry_point(self): "[project.scripts]" in content ), "No CLI entry point section in pyproject.toml" assert ( - "deepfreeze" in content + "elastic_deepfreeze" in content ), "deepfreeze CLI entry point not found in pyproject.toml" else: # If pyproject.toml not at expected location, just verify CLI works - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli assert cli is not None def test_package_has_version(self): """Verify package has version defined""" - import deepfreeze + import elastic_deepfreeze - assert hasattr(deepfreeze, "__version__") - assert deepfreeze.__version__ is not None - assert len(deepfreeze.__version__) > 0 + assert hasattr(elastic_deepfreeze, "__version__") + assert elastic_deepfreeze.__version__ is not None + assert len(elastic_deepfreeze.__version__) > 0 class TestVerificationScript: @@ -365,9 +365,9 @@ class TestVerificationScript: def test_verification_script_checks_imports_with_ast(self): """Use AST to verify no curator imports (ignores docstrings and comments)""" - import deepfreeze + import elastic_deepfreeze - package_dir = Path(deepfreeze.__file__).parent + package_dir = Path(elastic_deepfreeze.__file__).parent curator_imports = [] for py_file in package_dir.rglob("*.py"): @@ -394,9 +394,9 @@ def test_verification_script_checks_imports_with_ast(self): def test_no_es_client_builder_dependency_in_imports(self): """Verify no actual import statements use es_client.builder""" - import deepfreeze + import elastic_deepfreeze - package_dir = Path(deepfreeze.__file__).parent + package_dir = Path(elastic_deepfreeze.__file__).parent es_client_imports = [] for py_file in package_dir.rglob("*.py"): diff --git a/tests/cli/test_integration.py b/tests/cli/test_integration.py index b39ff83..c583030 100644 --- a/tests/cli/test_integration.py +++ b/tests/cli/test_integration.py @@ -11,7 +11,7 @@ from unittest.mock import MagicMock, patch -from deepfreeze import ( +from elastic_deepfreeze import ( Refreeze, Repository, Rotate, @@ -19,7 +19,7 @@ Setup, Thaw, ) -from deepfreeze_core.constants import THAW_STATUS_COMPLETED +from elastic_deepfreeze_core.constants import THAW_STATUS_COMPLETED class MockElasticsearchClient: @@ -171,14 +171,14 @@ def test_setup_then_status_workflow(self): mock_es.info.return_value = {"version": {"number": "8.10.0"}} # Run setup with all necessary patches - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.setup.ensure_settings_index"): - with patch("deepfreeze_core.actions.setup.save_settings"): - with patch("deepfreeze_core.actions.setup.create_repo"): + with patch("elastic_deepfreeze_core.actions.setup.ensure_settings_index"): + with patch("elastic_deepfreeze_core.actions.setup.save_settings"): + with patch("elastic_deepfreeze_core.actions.setup.create_repo"): with patch( - "deepfreeze_core.actions.setup.create_or_update_ilm_policy" + "elastic_deepfreeze_core.actions.setup.create_or_update_ilm_policy" ) as mock_ilm: mock_ilm.return_value = { "action": "created", @@ -186,7 +186,7 @@ def test_setup_then_status_workflow(self): } with patch( - "deepfreeze_core.actions.setup.update_index_template_ilm_policy" + "elastic_deepfreeze_core.actions.setup.update_index_template_ilm_policy" ) as mock_tmpl: mock_tmpl.return_value = { "action": "updated", @@ -226,14 +226,14 @@ def test_setup_then_rotate_workflow(self): mock_es.info.return_value = {"version": {"number": "8.10.0"}} # Setup phase - with patch("deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.setup.s3_client_factory") as mock_factory: mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.setup.ensure_settings_index"): - with patch("deepfreeze_core.actions.setup.save_settings"): - with patch("deepfreeze_core.actions.setup.create_repo"): + with patch("elastic_deepfreeze_core.actions.setup.ensure_settings_index"): + with patch("elastic_deepfreeze_core.actions.setup.save_settings"): + with patch("elastic_deepfreeze_core.actions.setup.create_repo"): with patch( - "deepfreeze_core.actions.setup.create_or_update_ilm_policy" + "elastic_deepfreeze_core.actions.setup.create_or_update_ilm_policy" ) as mock_ilm: mock_ilm.return_value = { "action": "created", @@ -241,7 +241,7 @@ def test_setup_then_rotate_workflow(self): } with patch( - "deepfreeze_core.actions.setup.update_index_template_ilm_policy" + "elastic_deepfreeze_core.actions.setup.update_index_template_ilm_policy" ) as mock_tmpl: mock_tmpl.return_value = { "action": "updated", @@ -267,10 +267,10 @@ def test_setup_then_rotate_workflow(self): # Rotate phase - the rotate action creates a new repository with new base_path # in the SAME bucket (rotate-bucket), not a new bucket - with patch("deepfreeze_core.actions.rotate.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.rotate.s3_client_factory") as mock_factory: mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.rotate.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.rotate.get_settings") as mock_get: mock_get.return_value = Settings( repo_name_prefix="rotate-test", bucket_name_prefix="rotate-bucket", @@ -279,7 +279,7 @@ def test_setup_then_rotate_workflow(self): ) with patch( - "deepfreeze_core.actions.rotate.get_matching_repos" + "elastic_deepfreeze_core.actions.rotate.get_matching_repos" ) as mock_repos: mock_repos.return_value = [ Repository( @@ -291,11 +291,11 @@ def test_setup_then_rotate_workflow(self): ] with patch( - "deepfreeze_core.actions.rotate.create_repo" + "elastic_deepfreeze_core.actions.rotate.create_repo" ) as mock_create_repo: - with patch("deepfreeze_core.actions.rotate.save_settings"): + with patch("elastic_deepfreeze_core.actions.rotate.save_settings"): with patch( - "deepfreeze_core.actions.rotate.create_versioned_ilm_policy" + "elastic_deepfreeze_core.actions.rotate.create_versioned_ilm_policy" ): rotate = Rotate( client=mock_es, @@ -320,14 +320,14 @@ def test_thaw_list_requests(self): mock_s3 = MockS3Client() # List mode - with patch("deepfreeze_core.actions.thaw.s3_client_factory") as mock_factory: + with patch("elastic_deepfreeze_core.actions.thaw.s3_client_factory") as mock_factory: mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.thaw.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.thaw.get_settings") as mock_get: mock_get.return_value = Settings() with patch( - "deepfreeze_core.actions.thaw.list_thaw_requests" + "elastic_deepfreeze_core.actions.thaw.list_thaw_requests" ) as mock_list: mock_list.return_value = [ { @@ -352,15 +352,15 @@ def test_refreeze_completed_request(self): # Refreeze the completed request with patch( - "deepfreeze_core.actions.refreeze.s3_client_factory" + "elastic_deepfreeze_core.actions.refreeze.s3_client_factory" ) as mock_factory: mock_factory.return_value = mock_s3 - with patch("deepfreeze_core.actions.refreeze.get_settings") as mock_get: + with patch("elastic_deepfreeze_core.actions.refreeze.get_settings") as mock_get: mock_get.return_value = Settings() with patch( - "deepfreeze_core.actions.refreeze.get_thaw_request" + "elastic_deepfreeze_core.actions.refreeze.get_thaw_request" ) as mock_req: mock_req.return_value = { "request_id": "thaw-completed", @@ -368,7 +368,7 @@ def test_refreeze_completed_request(self): "repos": ["lifecycle-repo-000001"], } - with patch("deepfreeze_core.utilities.get_repository") as mock_repo: + with patch("elastic_deepfreeze_core.utilities.get_repository") as mock_repo: mock_repo.return_value = Repository( name="lifecycle-repo-000001", bucket="lifecycle-bucket", @@ -378,9 +378,9 @@ def test_refreeze_completed_request(self): ) with patch( - "deepfreeze_core.actions.refreeze.update_thaw_request" + "elastic_deepfreeze_core.actions.refreeze.update_thaw_request" ): - with patch("deepfreeze_core.actions.refreeze.unmount_repo"): + with patch("elastic_deepfreeze_core.actions.refreeze.unmount_repo"): refreeze = Refreeze( client=mock_es, request_id="thaw-completed", @@ -414,7 +414,7 @@ def test_read_existing_settings_format(self): } # Verify we can read the settings - from deepfreeze_core.utilities import get_settings + from elastic_deepfreeze_core.utilities import get_settings settings = get_settings(mock_es) @@ -449,7 +449,7 @@ def test_read_existing_repository_format(self): } # Verify we can read the repository - from deepfreeze_core.utilities import get_repository + from elastic_deepfreeze_core.utilities import get_repository repo = get_repository(mock_es, "legacy-repo-000001") @@ -477,7 +477,7 @@ def test_read_existing_thaw_request_format(self): } # Verify we can read the thaw request - from deepfreeze_core.utilities import get_thaw_request + from elastic_deepfreeze_core.utilities import get_thaw_request request = get_thaw_request(mock_es, "thaw-legacy-001") diff --git a/tests/cli/test_package.py b/tests/cli/test_package.py index 9f9c593..90869ab 100644 --- a/tests/cli/test_package.py +++ b/tests/cli/test_package.py @@ -13,36 +13,36 @@ def test_package_imports_successfully(): """Test that the deepfreeze package can be imported""" - import deepfreeze + import elastic_deepfreeze - assert deepfreeze is not None - assert hasattr(deepfreeze, "__version__") - assert len(deepfreeze.__version__) > 0 # Version should be a non-empty string + assert elastic_deepfreeze is not None + assert hasattr(elastic_deepfreeze, "__version__") + assert len(elastic_deepfreeze.__version__) > 0 # Version should be a non-empty string def test_submodules_import_successfully(): """Test that all submodules can be imported""" - import deepfreeze.cli - import deepfreeze.config - import deepfreeze.validators - import deepfreeze_core.actions - import deepfreeze_core.constants - import deepfreeze_core.exceptions + import elastic_deepfreeze.cli + import elastic_deepfreeze.config + import elastic_deepfreeze.validators + import elastic_deepfreeze_core.actions + import elastic_deepfreeze_core.constants + import elastic_deepfreeze_core.exceptions - assert deepfreeze_core.exceptions is not None - assert deepfreeze_core.constants is not None - assert deepfreeze.cli is not None - assert deepfreeze_core.actions is not None - assert deepfreeze.config is not None - assert deepfreeze.validators is not None + assert elastic_deepfreeze_core.exceptions is not None + assert elastic_deepfreeze_core.constants is not None + assert elastic_deepfreeze.cli is not None + assert elastic_deepfreeze_core.actions is not None + assert elastic_deepfreeze.config is not None + assert elastic_deepfreeze.validators is not None def test_no_curator_imports_in_package(): """Test that no curator imports are present in the package""" # Get the package directory - import deepfreeze + import elastic_deepfreeze - package_dir = Path(deepfreeze.__file__).parent + package_dir = Path(elastic_deepfreeze.__file__).parent # Check all Python files in the package curator_imports_found = [] @@ -77,7 +77,7 @@ def test_no_curator_imports_in_package(): def test_entry_point_registration(): """Test that the CLI entry point is properly configured""" import click - from deepfreeze.cli.main import cli + from elastic_deepfreeze.cli.main import cli assert cli is not None assert isinstance(cli, click.core.Group) diff --git a/tests/cli/test_s3client.py b/tests/cli/test_s3client.py index eefaea5..9df34a4 100644 --- a/tests/cli/test_s3client.py +++ b/tests/cli/test_s3client.py @@ -24,10 +24,10 @@ class TestAwsS3ClientInstantiation: """Tests for AwsS3Client instantiation""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_client_instantiation_success(self, mock_boto3): """Test that AwsS3Client can be instantiated with valid credentials""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client # Mock successful list_buckets call mock_client = MagicMock() @@ -41,11 +41,11 @@ def test_client_instantiation_success(self, mock_boto3): mock_boto3.client.assert_called_once_with("s3") mock_client.list_buckets.assert_called_once() - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_client_instantiation_invalid_credentials(self, mock_boto3): """Test that AwsS3Client raises ActionError for invalid credentials""" from botocore.exceptions import ClientError - from deepfreeze import ActionError, AwsS3Client + from elastic_deepfreeze import ActionError, AwsS3Client # Mock failed list_buckets call mock_client = MagicMock() @@ -66,10 +66,10 @@ def test_client_instantiation_invalid_credentials(self, mock_boto3): class TestBucketExists: """Tests for bucket_exists method""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_bucket_exists_true(self, mock_boto3): """Test bucket_exists returns True when bucket exists""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -82,11 +82,11 @@ def test_bucket_exists_true(self, mock_boto3): assert result is True mock_client.head_bucket.assert_called_once_with(Bucket="test-bucket") - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_bucket_exists_false(self, mock_boto3): """Test bucket_exists returns False when bucket does not exist""" from botocore.exceptions import ClientError - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -103,10 +103,10 @@ def test_bucket_exists_false(self, mock_boto3): class TestListObjects: """Tests for list_objects method""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_list_objects_empty(self, mock_boto3): """Test list_objects returns empty list when no objects""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -122,10 +122,10 @@ def test_list_objects_empty(self, mock_boto3): assert result == [] - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_list_objects_with_results(self, mock_boto3): """Test list_objects returns objects when they exist""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -151,10 +151,10 @@ def test_list_objects_with_results(self, mock_boto3): class TestS3ClientFactory: """Tests for s3_client_factory function""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_factory_returns_aws_client(self, mock_boto3): """Test factory returns AwsS3Client for 'aws' provider""" - from deepfreeze import AwsS3Client, s3_client_factory + from elastic_deepfreeze import AwsS3Client, s3_client_factory mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -166,7 +166,7 @@ def test_factory_returns_aws_client(self, mock_boto3): def test_factory_raises_not_implemented_for_gcp(self): """Test factory raises NotImplementedError for 'gcp' provider""" - from deepfreeze import s3_client_factory + from elastic_deepfreeze import s3_client_factory with pytest.raises(NotImplementedError) as exc_info: s3_client_factory("gcp") @@ -175,7 +175,7 @@ def test_factory_raises_not_implemented_for_gcp(self): def test_factory_raises_not_implemented_for_azure(self): """Test factory raises NotImplementedError for 'azure' provider""" - from deepfreeze import s3_client_factory + from elastic_deepfreeze import s3_client_factory with pytest.raises(NotImplementedError) as exc_info: s3_client_factory("azure") @@ -184,7 +184,7 @@ def test_factory_raises_not_implemented_for_azure(self): def test_factory_raises_value_error_for_invalid_provider(self): """Test factory raises ValueError for invalid provider""" - from deepfreeze import s3_client_factory + from elastic_deepfreeze import s3_client_factory with pytest.raises(ValueError) as exc_info: s3_client_factory("invalid") @@ -195,10 +195,10 @@ def test_factory_raises_value_error_for_invalid_provider(self): class TestS3ClientOperations: """Tests for various S3Client operations""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_test_connection_success(self, mock_boto3): """Test test_connection returns True when connection succeeds""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -209,11 +209,11 @@ def test_test_connection_success(self, mock_boto3): assert result is True - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_test_connection_failure(self, mock_boto3): """Test test_connection returns False when connection fails""" from botocore.exceptions import ClientError - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() # First call succeeds (for init) @@ -237,10 +237,10 @@ def test_test_connection_failure(self, mock_boto3): class TestBucketOperations: """Tests for bucket create and delete operations (Task Group 17)""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_create_bucket_success(self, mock_boto3): """Test create_bucket creates bucket successfully""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -262,10 +262,10 @@ def test_create_bucket_success(self, mock_boto3): mock_client.create_bucket.assert_called_once_with(Bucket="new-bucket") - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_create_bucket_already_exists(self, mock_boto3): """Test create_bucket raises error when bucket exists""" - from deepfreeze import ActionError, AwsS3Client + from elastic_deepfreeze import ActionError, AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -279,10 +279,10 @@ def test_create_bucket_already_exists(self, mock_boto3): assert "already exists" in str(exc_info.value) - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_delete_bucket_success(self, mock_boto3): """Test delete_bucket deletes bucket successfully""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -293,10 +293,10 @@ def test_delete_bucket_success(self, mock_boto3): mock_client.delete_bucket.assert_called_once_with(Bucket="delete-me-bucket") - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_delete_bucket_force(self, mock_boto3): """Test delete_bucket with force=True empties bucket first""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -318,10 +318,10 @@ def test_delete_bucket_force(self, mock_boto3): class TestObjectOperations: """Tests for object put, head, and copy operations (Task Group 17)""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_put_object_success(self, mock_boto3): """Test put_object successfully puts object""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -334,10 +334,10 @@ def test_put_object_success(self, mock_boto3): Bucket="test-bucket", Key="test-key", Body="test-body" ) - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_head_object_success(self, mock_boto3): """Test head_object returns metadata""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -357,10 +357,10 @@ def test_head_object_success(self, mock_boto3): Bucket="test-bucket", Key="test-key" ) - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_copy_object_success(self, mock_boto3): """Test copy_object copies with storage class""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -381,10 +381,10 @@ def test_copy_object_success(self, mock_boto3): StorageClass="GLACIER", ) - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_list_buckets_with_prefix(self, mock_boto3): """Test list_buckets filters by prefix""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = { @@ -408,10 +408,10 @@ def test_list_buckets_with_prefix(self, mock_boto3): class TestThawRefreezeOperations: """Tests for thaw and refreeze operations (Task Group 17)""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_thaw_initiates_restore_for_glacier_objects(self, mock_boto3): """Test thaw initiates restore for Glacier storage class objects""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -436,10 +436,10 @@ def test_thaw_initiates_restore_for_glacier_objects(self, mock_boto3): # Should have called restore_object twice (only for GLACIER and DEEP_ARCHIVE) assert mock_client.restore_object.call_count == 2 - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_thaw_skips_objects_outside_base_path(self, mock_boto3): """Test thaw skips objects that don't start with base_path""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -463,10 +463,10 @@ def test_thaw_skips_objects_outside_base_path(self, mock_boto3): # Should have called restore_object only once assert mock_client.restore_object.call_count == 1 - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_refreeze_copies_objects_to_glacier(self, mock_boto3): """Test refreeze copies objects to GLACIER storage class""" - from deepfreeze import AwsS3Client + from elastic_deepfreeze import AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -493,11 +493,11 @@ def test_refreeze_copies_objects_to_glacier(self, mock_boto3): class TestS3ClientErrorHandling: """Tests for error handling in S3 operations (Task Group 17)""" - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_head_object_raises_action_error(self, mock_boto3): """Test head_object raises ActionError on failure""" from botocore.exceptions import ClientError - from deepfreeze import ActionError, AwsS3Client + from elastic_deepfreeze import ActionError, AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} @@ -513,11 +513,11 @@ def test_head_object_raises_action_error(self, mock_boto3): assert "Error getting metadata" in str(exc_info.value) - @patch("deepfreeze_core.s3client.boto3") + @patch("elastic_deepfreeze_core.s3client.boto3") def test_bucket_exists_raises_on_unexpected_error(self, mock_boto3): """Test bucket_exists raises ActionError on unexpected errors""" from botocore.exceptions import ClientError - from deepfreeze import ActionError, AwsS3Client + from elastic_deepfreeze import ActionError, AwsS3Client mock_client = MagicMock() mock_client.list_buckets.return_value = {"Buckets": []} diff --git a/tests/cli/test_utilities.py b/tests/cli/test_utilities.py index 56992b4..dac456c 100644 --- a/tests/cli/test_utilities.py +++ b/tests/cli/test_utilities.py @@ -22,7 +22,7 @@ class TestSettingsOperations: def test_ensure_settings_index_creates_when_missing(self): """Test ensure_settings_index creates index when missing and flag is True""" - from deepfreeze_core import ensure_settings_index + from elastic_deepfreeze_core import ensure_settings_index mock_client = MagicMock() mock_client.indices.exists.return_value = False @@ -37,8 +37,8 @@ def test_ensure_settings_index_creates_when_missing(self): def test_ensure_settings_index_raises_when_missing_no_create(self): """Test ensure_settings_index raises MissingIndexError when missing and flag is False""" - from deepfreeze import MissingIndexError - from deepfreeze_core import ensure_settings_index + from elastic_deepfreeze import MissingIndexError + from elastic_deepfreeze_core import ensure_settings_index mock_client = MagicMock() mock_client.indices.exists.return_value = False @@ -48,7 +48,7 @@ def test_ensure_settings_index_raises_when_missing_no_create(self): def test_ensure_settings_index_does_nothing_when_exists(self): """Test ensure_settings_index does nothing when index exists""" - from deepfreeze_core import ensure_settings_index + from elastic_deepfreeze_core import ensure_settings_index mock_client = MagicMock() mock_client.indices.exists.return_value = True @@ -59,8 +59,8 @@ def test_ensure_settings_index_does_nothing_when_exists(self): def test_get_settings_returns_settings_object(self): """Test get_settings returns a Settings object when found""" - from deepfreeze import Settings - from deepfreeze_core import get_settings + from elastic_deepfreeze import Settings + from elastic_deepfreeze_core import get_settings mock_client = MagicMock() mock_client.indices.exists.return_value = True @@ -80,7 +80,7 @@ def test_get_settings_returns_settings_object(self): def test_get_settings_returns_none_when_not_found(self): """Test get_settings returns None when settings not found""" - from deepfreeze_core import get_settings + from elastic_deepfreeze_core import get_settings from elasticsearch8 import NotFoundError mock_client = MagicMock() @@ -93,8 +93,8 @@ def test_get_settings_returns_none_when_not_found(self): def test_save_settings_creates_new(self): """Test save_settings creates new document when not exists""" - from deepfreeze import Settings - from deepfreeze_core import save_settings + from elastic_deepfreeze import Settings + from elastic_deepfreeze_core import save_settings from elasticsearch8 import NotFoundError mock_client = MagicMock() @@ -108,8 +108,8 @@ def test_save_settings_creates_new(self): def test_save_settings_updates_existing(self): """Test save_settings updates document when exists""" - from deepfreeze import Settings - from deepfreeze_core import save_settings + from elastic_deepfreeze import Settings + from elastic_deepfreeze_core import save_settings mock_client = MagicMock() mock_client.get.return_value = {"_source": {}} @@ -126,8 +126,8 @@ class TestRepositoryOperations: def test_get_repository_returns_repository_when_found(self): """Test get_repository returns Repository when found in status index""" - from deepfreeze import Repository - from deepfreeze_core.utilities import get_repository + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.utilities import get_repository mock_client = MagicMock() mock_client.search.return_value = { @@ -155,8 +155,8 @@ def test_get_repository_returns_repository_when_found(self): def test_get_repository_returns_empty_when_not_found(self): """Test get_repository returns new Repository when not found""" - from deepfreeze import Repository - from deepfreeze_core.utilities import get_repository + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core.utilities import get_repository mock_client = MagicMock() mock_client.search.return_value = {"hits": {"total": {"value": 0}, "hits": []}} @@ -169,8 +169,8 @@ def test_get_repository_returns_empty_when_not_found(self): def test_get_all_repos_returns_list(self): """Test get_all_repos returns list of Repository objects""" - from deepfreeze import Repository - from deepfreeze_core import get_all_repos + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core import get_all_repos mock_client = MagicMock() mock_client.search.return_value = { @@ -205,7 +205,7 @@ def test_get_all_repos_returns_list(self): def test_get_matching_repos_filters_by_prefix(self): """Test get_matching_repos filters repositories by prefix""" - from deepfreeze_core import get_matching_repos + from elastic_deepfreeze_core import get_matching_repos mock_client = MagicMock() mock_client.search.return_value = { @@ -242,7 +242,7 @@ class TestDateOperations: def test_decode_date_from_string(self): """Test decode_date converts ISO string to datetime""" - from deepfreeze_core import decode_date + from elastic_deepfreeze_core import decode_date result = decode_date("2023-06-15T10:30:00+00:00") @@ -253,7 +253,7 @@ def test_decode_date_from_string(self): def test_decode_date_from_datetime(self): """Test decode_date handles datetime input""" - from deepfreeze_core import decode_date + from elastic_deepfreeze_core import decode_date input_dt = datetime(2023, 6, 15, 10, 30, 0, tzinfo=timezone.utc) @@ -263,7 +263,7 @@ def test_decode_date_from_datetime(self): def test_decode_date_adds_utc_if_naive(self): """Test decode_date adds UTC timezone to naive datetime""" - from deepfreeze_core import decode_date + from elastic_deepfreeze_core import decode_date result = decode_date("2023-06-15T10:30:00") @@ -271,14 +271,14 @@ def test_decode_date_adds_utc_if_naive(self): def test_decode_date_invalid_raises(self): """Test decode_date raises ValueError for invalid input""" - from deepfreeze_core import decode_date + from elastic_deepfreeze_core import decode_date with pytest.raises(ValueError): decode_date(12345) # Neither string nor datetime def test_get_next_suffix_oneup(self): """Test get_next_suffix with oneup style""" - from deepfreeze_core import get_next_suffix + from elastic_deepfreeze_core import get_next_suffix result = get_next_suffix("oneup", "000041", None, None) @@ -286,7 +286,7 @@ def test_get_next_suffix_oneup(self): def test_get_next_suffix_date(self): """Test get_next_suffix with date style""" - from deepfreeze_core import get_next_suffix + from elastic_deepfreeze_core import get_next_suffix result = get_next_suffix("date", "000001", 2024, 3) @@ -294,15 +294,15 @@ def test_get_next_suffix_date(self): def test_get_next_suffix_invalid_raises(self): """Test get_next_suffix raises for invalid style""" - from deepfreeze_core import get_next_suffix + from elastic_deepfreeze_core import get_next_suffix with pytest.raises(ValueError): get_next_suffix("invalid_style", "000001", None, None) def test_find_repos_by_date_range(self): """Test find_repos_by_date_range queries with correct date filters""" - from deepfreeze import Repository - from deepfreeze_core import find_repos_by_date_range + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core import find_repos_by_date_range mock_client = MagicMock() mock_client.search.return_value = { @@ -336,8 +336,8 @@ class TestThawRequestOperations: def test_save_thaw_request_creates_document(self): """Test save_thaw_request creates a thaw request document""" - from deepfreeze import Repository - from deepfreeze_core import save_thaw_request + from elastic_deepfreeze import Repository + from elastic_deepfreeze_core import save_thaw_request mock_client = MagicMock() repos = [Repository(name="repo-1"), Repository(name="repo-2")] @@ -357,7 +357,7 @@ def test_save_thaw_request_creates_document(self): def test_get_thaw_request_returns_document(self): """Test get_thaw_request retrieves thaw request""" - from deepfreeze_core import get_thaw_request + from elastic_deepfreeze_core import get_thaw_request mock_client = MagicMock() mock_client.get.return_value = { @@ -375,7 +375,7 @@ def test_get_thaw_request_returns_document(self): def test_list_thaw_requests_returns_all(self): """Test list_thaw_requests returns all thaw requests""" - from deepfreeze_core import list_thaw_requests + from elastic_deepfreeze_core import list_thaw_requests mock_client = MagicMock() mock_client.search.return_value = { @@ -409,7 +409,7 @@ def test_list_thaw_requests_returns_all(self): def test_update_thaw_request(self): """Test update_thaw_request updates status""" - from deepfreeze_core.utilities import update_thaw_request + from elastic_deepfreeze_core.utilities import update_thaw_request mock_client = MagicMock() @@ -428,7 +428,7 @@ def test_no_curator_imports_in_utilities(self): """Test that utilities.py has no curator imports (actual import statements, not docstrings)""" import inspect - import deepfreeze_core.utilities as util_module + import elastic_deepfreeze_core.utilities as util_module source = inspect.getsource(util_module) @@ -441,9 +441,9 @@ def test_no_curator_imports_in_utilities(self): def test_module_uses_local_exceptions(self): """Test that utilities uses deepfreeze.exceptions""" - from deepfreeze import ActionError as DFActionError - from deepfreeze import MissingIndexError as DFMissingIndexError - from deepfreeze_core import ActionError, MissingIndexError + from elastic_deepfreeze import ActionError as DFActionError + from elastic_deepfreeze import MissingIndexError as DFMissingIndexError + from elastic_deepfreeze_core import ActionError, MissingIndexError # Verify they are the same classes assert ActionError is DFActionError @@ -455,7 +455,7 @@ class TestAllUtilityFunctionsAccessible: def test_repository_functions_exist(self): """Test repository operation functions are importable""" - from deepfreeze_core.utilities import ( + from elastic_deepfreeze_core.utilities import ( create_repo, get_all_repos, get_matching_repo_names, @@ -475,7 +475,7 @@ def test_repository_functions_exist(self): def test_settings_functions_exist(self): """Test settings operation functions are importable""" - from deepfreeze_core import ( + from elastic_deepfreeze_core import ( ensure_settings_index, get_settings, save_settings, @@ -487,7 +487,7 @@ def test_settings_functions_exist(self): def test_date_functions_exist(self): """Test date operation functions are importable""" - from deepfreeze_core import ( + from elastic_deepfreeze_core import ( decode_date, find_repos_by_date_range, get_timestamp_range, @@ -499,7 +499,7 @@ def test_date_functions_exist(self): def test_ilm_functions_exist(self): """Test ILM operation functions are importable""" - from deepfreeze_core.utilities import ( + from elastic_deepfreeze_core.utilities import ( create_ilm_policy, create_or_update_ilm_policy, create_thawed_ilm_policy, @@ -513,7 +513,7 @@ def test_ilm_functions_exist(self): def test_thaw_functions_exist(self): """Test thaw operation functions are importable""" - from deepfreeze_core.utilities import ( + from elastic_deepfreeze_core.utilities import ( get_thaw_request, list_thaw_requests, save_thaw_request, @@ -527,7 +527,7 @@ def test_thaw_functions_exist(self): def test_s3_functions_exist(self): """Test S3 operation functions are importable""" - from deepfreeze_core import ( + from elastic_deepfreeze_core import ( check_restore_status, push_to_glacier, ) @@ -537,7 +537,7 @@ def test_s3_functions_exist(self): def test_index_functions_exist(self): """Test index operation functions are importable""" - from deepfreeze_core.utilities import ( + from elastic_deepfreeze_core.utilities import ( find_and_mount_indices_in_date_range, find_snapshots_for_index, get_all_indices_in_repo, diff --git a/tests/cli/test_validators.py b/tests/cli/test_validators.py index 22a06c8..b937209 100644 --- a/tests/cli/test_validators.py +++ b/tests/cli/test_validators.py @@ -1,8 +1,8 @@ """Tests for the deepfreeze validators module""" import pytest -from deepfreeze import defaults -from deepfreeze.validators import ( +from elastic_deepfreeze import defaults +from elastic_deepfreeze.validators import ( ACTION_SCHEMAS, DEEPFREEZE_OPTIONS, get_default_options,