Skip to content

Commit

Permalink
tests: don't depend on code location
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Mar 21, 2024
1 parent 4cc1540 commit 655c36f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/unit/api/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def view(context, request):
assert request.response.content_type is None


def test_includeme():
def test_includeme(monkeypatch):
# We use `str(Path(__file__).parent / 'openapi.yaml'` to get the path.
# In our test, monkeypatch to a known value.
monkeypatch.setattr(config, "__file__", "/mnt/dummy/config.py")

conf = pretend.stub(
add_view_deriver=pretend.call_recorder(
Expand All @@ -67,9 +70,7 @@ def test_includeme():
assert conf.add_view_deriver.calls == [pretend.call(config._api_set_content_type)]
assert conf.include.calls == [pretend.call("pyramid_openapi3")]
assert conf.pyramid_openapi3_spec.calls == [
pretend.call(
"/opt/warehouse/src/warehouse/api/openapi.yaml", route="/api/openapi.yaml"
)
pretend.call("/mnt/dummy/openapi.yaml", route="/api/openapi.yaml")
]
assert conf.pyramid_openapi3_add_deserializer.calls == [
pretend.call("application/vnd.pypi.api-v0-danger+json", orjson.loads)
Expand Down

0 comments on commit 655c36f

Please sign in to comment.