Skip to content

Commit

Permalink
Fix specifying a different Hoverfly image
Browse files Browse the repository at this point in the history
  • Loading branch information
WouldYouKindly committed Jul 6, 2021
1 parent 07d0f9f commit 87ecb69
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.0.2] - 2021-07-06
### Fixed
- Fix specifying a different Hoverfly image
### Changed
- Bumped default Hoverfly image to 1.3.2

## [4.0.2] - 2021-06-11
### Fixed
- Wait until container's ports are available before considering it created
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ tell it to use Hoverfly as HTTP(S) proxy and to trust Hoverfly's certificate. Se

#### How to re-record a test
Add `record=True` again, and run the test. The simulation file will be overwritten.


#### Change Hoverfly version
To use a different Hoverfly version, specify `--hoverfly-image`. It must be a valid Docker image tag.

#### Start Hoverfly with custom parameters
Use `--hoverfly-args`. It is passed as is to a Hoverfly container.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest_hoverfly"
version = "4.0.2"
version = "4.0.3"
description = "Simplify working with Hoverfly from pytest"
authors = ["Devops team at Wrike <[email protected]>"]
repository = "https://github.com/wrike/pytest-hoverfly"
Expand Down
11 changes: 6 additions & 5 deletions pytest_hoverfly/pytest_hoverfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def __call__(
*,
record: bool = False,
stateful: bool = False,
postprocess: t.Callable[[], t.Any],
enable_default_postprocessing: bool = True,
) -> t.Callable[..., t.Any]:
...

Expand All @@ -43,7 +41,7 @@ def pytest_addoption(parser):
parser.addoption(
"--hoverfly-simulation-path",
dest="hoverfly_simulation_path",
help="Path to a directory with simulation files. " "Environment variables will be expanded.",
help="Path to a directory with simulation files. Environment variables will be expanded.",
type=Path,
)

Expand All @@ -57,7 +55,7 @@ def pytest_addoption(parser):
"--hoverfly-cert",
dest="hoverfly_cert",
default=Path(__file__).parent / "cert.pem",
help="Path to hoverfly SSL certificate. Needed " "for requests and aiohttp to trust hoverfly.",
help="Path to hoverfly SSL certificate. Needed for requests and aiohttp to trust hoverfly.",
type=Path,
)

Expand Down Expand Up @@ -150,7 +148,10 @@ def hoverfly_instance(request) -> Hoverfly:
2. Instance managed by plugin. Container will be created and destroyed after.
"""
yield from get_container(create_container_kwargs={"command": request.config.option.hoverfly_args})
yield from get_container(
create_container_kwargs={"command": request.config.option.hoverfly_args},
image=request.config.option.hoverfly_image,
)


@pytest.fixture
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pytest_hoverfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_simulation_replayer():


def test_hoverfly_decorator_recorder(testdir, tmpdir):
"""This test hits a network!"""
# create a temporary pytest test file
testdir.makepyfile(
"""
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_stateful_simulation_recorder():


def test_hoverfly_decorator_stateful_recorder(testdir, tmpdir):
"""This test hits a network!"""
# create a temporary pytest test file
testdir.makepyfile(
"""
Expand Down Expand Up @@ -183,6 +185,8 @@ def test_lack_of_unintended_side_effects():
This test must be run after at least one hoverfly-using test has
been run, so that session-scoped fixtures with potential side-effects
are initialized.
This test hits a network!
"""
resp = requests.get("https://foaas.com/version", headers={"Accept": "application/json"})

Expand Down

0 comments on commit 87ecb69

Please sign in to comment.