Skip to content

Commit

Permalink
Remove exact FOAAS version from tests, as it changes surprisingly often
Browse files Browse the repository at this point in the history
  • Loading branch information
WouldYouKindly committed Jun 11, 2021
1 parent 3e78a9d commit d840297
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_pytest_hoverfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
from pathlib import Path
from unittest.mock import ANY

import pytest
import requests
Expand Down Expand Up @@ -105,6 +106,7 @@ def test_hoverfly_decorator_recorder(testdir, tmpdir):
# create a temporary pytest test file
testdir.makepyfile(
"""
from unittest.mock import ANY
import pytest
import requests
from pytest_hoverfly import hoverfly
Expand All @@ -117,7 +119,7 @@ def test_stateful_simulation_recorder():
)
assert resp.json() == {'message': 'Version 2.1.1', 'subtitle': 'FOAAS'}
assert resp.json() == {'message': ANY, 'subtitle': 'FOAAS'}
"""
)

Expand All @@ -130,13 +132,14 @@ def test_stateful_simulation_recorder():
simulation = json.load(f)

assert len(simulation["data"]["pairs"]) == 1
assert simulation["data"]["pairs"][0]["response"]["body"] == '{"message":"Version 2.1.1","subtitle":"FOAAS"}'
assert "FOAAS" in simulation["data"]["pairs"][0]["response"]["body"]


def test_hoverfly_decorator_stateful_recorder(testdir, tmpdir):
# create a temporary pytest test file
testdir.makepyfile(
"""
from unittest.mock import ANY
import pytest
import requests
from pytest_hoverfly import hoverfly
Expand All @@ -154,7 +157,7 @@ def test_stateful_simulation_recorder():
headers={'Accept': 'application/json'},
)
assert resp.json() == {'message': 'Version 2.1.1', 'subtitle': 'FOAAS'}
assert resp.json() == {'message': ANY, 'subtitle': 'FOAAS'}
"""
)

Expand Down Expand Up @@ -184,7 +187,7 @@ def test_lack_of_unintended_side_effects():
resp = requests.get("https://foaas.com/version", headers={"Accept": "application/json"})

try:
assert resp.json() == {"message": "Version 2.1.1", "subtitle": "FOAAS"}, resp.text
assert resp.json() == {"message": ANY, "subtitle": "FOAAS"}, resp.text
except json.decoder.JSONDecodeError:
pytest.fail(resp.text + "\n\n(Request went to Hoverfly insted of foaas.com)")

Expand Down

0 comments on commit d840297

Please sign in to comment.