Simple, ergonomic Helm manifest fixtures for pytest.
Project description
pytest-helm
pytest-helm makes it easy to test Helm charts in a simple and repeatable fashion.
It runs a helm template command, loads your manifests into a fixture, and then allows you to make simple assertions about it's shape/contents.
Quickstart
Add pytest-helm
uv add pytest-helm
Scaffold out the fixture/test file
We assume you won't have pytest configured for a chart directory, so if that's the case you can run:
uv run pytest-helm --init
That will create two sample test files, a fixture in tests/conftest.py and a test in tests/test_deployment.py.
If you are already using pytest, you can skip this step.
Usage
Define as many fixtures as you'd like in conftest:
# tests/conftest.py
from pytest_helm import manifest_fixture
chart = manifest_fixture(
"chart",
["helm", "template", ".", "-f", "values.yaml"],
)
prod_chart = manifest_fixture(
"prod_chart",
["helm", "template", ".", "-f", "prod-values.yaml"],
)
Write tests to validate the YAML shape/output for different values meets your requirements:
# tests/test_deployments.py
def test_it_provisions_one_replica_by_default(chart):
api = chart.get("deployment/api-server")
assert api.spec.replicas == 1
def test_it_provisions_multiple_replicas_in_prod(prod_chart):
api = prod_chart.get("deployment/api-server")
assert = api.spec.replicas == 3
Use PDB to programatically inspect your manifests:
def test_idk_what_to_test(chart):
import pdb; pdb.set_trace()
$ pytest
(Pdb) chart
ManifestIndex({
'ConfigMap': ['release-name-base-config'],
'Deployment': ['release-name-api', 'release-name-worker'],
'Ingress': ['release-name-app'],
'Job': ['release-name-db-migrate'],
'Service': ['release-name-api'],
'ServiceAccount': ['backend']
})
(Pdb) chart.get("configmap/release-name-base-config")
Box({'apiVersion': 'v1', 'kind': 'ConfigMap', 'metadata': {'name': 'release-name-base-config'}, 'data': {'EMAIL_FROM': 'foo@bar.com'}})
(Pdb)
Notes:
chart.get()is case-insensitive,chart.get("ConfigMap/foo")andchart.get("configmap/foo")are the same thing- In the event that two resources have the same name/kind, you are required to pass an apiVersion as well, i.e.
v1/ConfigMap/foo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_helm-0.1.1.tar.gz.
File metadata
- Download URL: pytest_helm-0.1.1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb214ccdd0dcbd9d8b21ed68f911e2fc29339a23a412fde109fa19be48f9e88a
|
|
| MD5 |
73262a05e0a3b4158e28eb89251150ff
|
|
| BLAKE2b-256 |
90ad986b8a03ae1cb9206928a9a7d327fdd36a6463a57ed6a4abae709c7f4518
|
Provenance
The following attestation bundles were made for pytest_helm-0.1.1.tar.gz:
Publisher:
publish.yml on thomasv314/pytest-helm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_helm-0.1.1.tar.gz -
Subject digest:
bb214ccdd0dcbd9d8b21ed68f911e2fc29339a23a412fde109fa19be48f9e88a - Sigstore transparency entry: 975264958
- Sigstore integration time:
-
Permalink:
thomasv314/pytest-helm@c4f772a7f7d460040a128d1863a78797c372b514 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/thomasv314
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4f772a7f7d460040a128d1863a78797c372b514 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_helm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pytest_helm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df92db6e08e6aff0fb8e87e603cc63df44dba06c223f2115f281e8a965c801dc
|
|
| MD5 |
a82fc9604ced09152bf8c52a1cbbfdea
|
|
| BLAKE2b-256 |
5845078fe9b0daa85321fd4e0abb93e8ddeec2bace3ba6811ee1c6df52f5251c
|
Provenance
The following attestation bundles were made for pytest_helm-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on thomasv314/pytest-helm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_helm-0.1.1-py3-none-any.whl -
Subject digest:
df92db6e08e6aff0fb8e87e603cc63df44dba06c223f2115f281e8a965c801dc - Sigstore transparency entry: 975264962
- Sigstore integration time:
-
Permalink:
thomasv314/pytest-helm@c4f772a7f7d460040a128d1863a78797c372b514 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/thomasv314
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4f772a7f7d460040a128d1863a78797c372b514 -
Trigger Event:
push
-
Statement type: