Tyler Chamberlain
01/11/2025, 7:42 PMwiremock_mappings/some_thing.py
would contain something like
Mapping(
request=MappingRequest(method=HttpMethods.GET, url="/some/thing"),
response=MappingResponse(status=200, body="Hello, world!", headers=("Content-Type", "text/plain")),
)
i can write custom code to load up files from the folder and add them as mappings, but does that already exist somewhere i can leverage? seems like it might be a common use case. i see i can do JSON files and specify a folder, but specifically id like to keep them as python files to be more flexible.Lee Turner
01/11/2025, 9:40 PMLee Turner
01/11/2025, 9:41 PMTyler Chamberlain
01/11/2025, 9:49 PMdef add_mappings_from_folder():
mappings_folder = f"{settings.app_dir}/../sample_app/wiremock_mappings/"
import os
for module in os.listdir(mappings_folder):
if module == '__init__.py' or module[-3:] != '.py':
continue
__import__(f"sample_app.wiremock_mappings.{module[:-3]}", locals(), globals())
del module