Testing the GasBuddy Integration

SkillDev tools

Guide and instructions on how to run tests, set up test environments, and mock HTTP layers in the ha-gasbuddy repository.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Testing the GasBuddy Integration skill

What this skill tells your AI

The instructions your AI receives, as published by firstof9/ha-gasbuddy in .agents/skills/test_integration/SKILL.md and read by ahel’s review.

This guide helps AI agents run and add tests in this repository.

Environment & Run Commands

Ensure you are using the correct Python version (target is 3.14) and dependencies:

# Setup virtual environment
uv venv --python 3.14
uv pip install -r requirements_test.txt
uv pip install 'ruff==0.15.14'

# Run the test suite
.venv/bin/python -m pytest -q --no-header

Adding New Tests

Add new test cases to tests/. Identify the target area to add tests:

  • test_config_flow.py: Form steps, reconfigurations, and options validation.
  • test_init.py: Component setup, uninstallation, migration logic, and background services.
  • test_sensor.py: Price state assertions, unit of measure changes, and device attribute assertions.
  • 100% Coverage Rule: All patch/added code in the PR must have 100% test coverage before submission.

Test Mocking Guidelines

  • HTTP Mocking: Use aioresponses to mock the GraphQL endpoints (https://www.gasbuddy.com/graphql) and the web client page (https://www.gasbuddy.com/home).
  • Method Patching: Avoid bypassing price_lookup on py_gasbuddy.GasBuddy by directly calling process_request in code, as this breaks existing HTTP-level mocks. Patch at the public method level or configure appropriate mock responses.

Signals

GitHub stars
65
Forks
12
Last commit
Sep 2026

ahel review

  • K1binfo
    installs-packages

Automated review, not a security audit. Ruleset v1+k2.

Advanced
Catalog kind
skill
Gateway key
test-integration
Source
github.com/firstof9/ha-gasbuddy