Metadata-Version: 2.4
Name: pytest-jupyter-deploy
Version: 0.1.0
Summary: Pytest plugin for E2E testing of jupyter-deploy templates
Project-URL: Homepage, https://github.com/jupyter-infra/jupyter-deploy
Project-URL: Repository, https://github.com/jupyter-infra/jupyter-deploy/tree/main/libs/pytest-jupyter-deploy
Project-URL: Issues, https://github.com/jupyter-infra/jupyter-deploy/issues
Author-email: Jonathan Guinegagne <jggg@amazon.com>, Michael Chin <chnmch@amazon.com>, Brian Granger <brgrange@amazon.com>
License: MIT License
        
        Copyright (c) Amazon Web Services
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.12
Requires-Dist: jupyter-deploy
Requires-Dist: pexpect>=4.9.0
Requires-Dist: pytest-order>=1.3.0
Requires-Dist: pytest>=8.3.5
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: requests>=2.32.0
Provides-Extra: ui
Requires-Dist: pytest-playwright>=0.7.2; extra == 'ui'
Description-Content-Type: text/markdown

# pytest-jupyter-deploy

Pytest plugin for E2E testing of jupyter-deploy templates.

## Overview

This package provides pytest fixtures and utilities for writing end-to-end tests for jupyter-deploy templates. It handles deployment lifecycle management, configuration loading, and provides helpers for testing web applications with Playwright.

## Installation

```bash
pip install pytest-jupyter-deploy
```

For UI testing with Playwright:
```bash
pip install pytest-jupyter-deploy[ui]
playwright install firefox
```

## Fixtures

- **`e2e_deployment`** (session-scoped): Manages deployment lifecycle (init, config, up, down)
- **`e2e_config`** (session-scoped): Provides access to suite configuration
- **`e2e_suite_dir`** (session-scoped): Path to the E2E tests directory
- **`github_oauth_app`** (function-scoped): Helper for GitHub OAuth2 Proxy authentication with passkey support

## Usage

The plugin is automatically loaded by pytest when installed. Use the provided fixtures in your tests.

### Example Test

```python
from pytest_jupyter_deploy.deployment import EndToEndDeployment

def test_host_running(e2e_deployment: EndToEndDeployment) -> None:
    """Test that the host is running."""
    e2e_deployment.ensure_deployed()
    host_status = e2e_deployment.cli.get_host_status()
    assert host_status == "running"
```

### Running Tests

```bash
# Run E2E tests
pytest -m e2e

# Run against existing deployment
pytest -m e2e --e2e-existing-project=sandbox3

# Capture screenshots on failure
pytest -m e2e --screenshot only-on-failure
```

## Test Utilities

The plugin provides helper functions to use directly in your tests.

### Deployment helpers

```python
from pytest_jupyter_deploy.undeployed_project import undeployed_project

def test_init_project(e2e_config: SuiteConfig) -> None:
    with undeployed_project(e2e_config) as (project_dir, cli):
        result = cli.run_command("show --variables --list")
        assert result.returncode == 0
```

### Decorators

```python
from pytest_jupyter_deploy.plugin import skip_if_testvars_not_set

@skip_if_testvars_not_set(["JD_E2E_USER", "JD_E2E_ORG"])
def test_requires_env_vars(e2e_deployment: EndToEndDeployment) -> None:
    ...
```

## E2E Test Container Image

This package bundles a Dockerfile and docker-compose.yml for a containerized E2E test environment
with Python, Terraform, AWS CLI, and Playwright pre-installed. The image is template-independent
and used by the [jupyter-deploy justfile](https://github.com/jupyter-infra/jupyter-deploy/blob/main/justfile)
to run E2E tests locally.

```python
from pytest_jupyter_deploy.image import IMAGE_PATH
# IMAGE_PATH points to the directory containing Dockerfile and docker-compose.yml
```

## License

The Pytest plugin for Jupyter Deploy templates is licensed under the [MIT License](LICENSE).
