From b4693fc3020ba46674a5bfb6e3711c31302a035b Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Wed, 12 Jul 2023 17:38:38 +0200 Subject: [PATCH 01/52] Restructure the documentation, merge READMEs --- CONTRIBUTING.md | 22 +++++++++ README.md | 88 ++++------------------------------ docs/api-client.md | 73 ++++++++++++++++++++++++++++ docs/changelog.md | 5 ++ docs/index.md | 48 +++++++++---------- docs/install.md | 32 +++++++++++++ docs/quickstart.md | 105 ++++++++++++++++++----------------------- docs/testcontainers.md | 2 +- mkdocs.yml | 9 ++++ 9 files changed, 221 insertions(+), 163 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 docs/api-client.md create mode 100644 docs/install.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..098f008 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing to Python WireMock + +[![a](https://img.shields.io/badge/slack-%23wiremock%2Fpython-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) + +## Get Started + +1. Join us ion the `#wiremock-python` channel on the [WireMock Slack](https://slack.wiremock.org/) +2. Check out the GitHub issues! + +## Pull Requests + +General Rules: + +- All Tests must pass +- Coverage shouldn't decrease +- All Pull Requests should be rebased against master **before** submitting the PR. + +## Development + +Setup the project using poetry. + +`poetry install` diff --git a/README.md b/README.md index 88c853d..6c04a2f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Python WireMock Admin API Client +# Python WireMock

@@ -6,7 +6,8 @@

-Python Wiremock is an HTTP client that allows users to interact with a Wiremock instance from within a Python project. +Python WireMock is a library that allows users to interact with a WireMock instance from within a Python project. +Full documentation can be found at [wiremock.readthedocs.org](http://wiremock.readthedocs.org/). [![a](https://img.shields.io/badge/slack-%23wiremock%2Fpython-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) [![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](http://wiremock.readthedocs.org/) @@ -20,66 +21,15 @@ FIXME: Reporting is dead: https://github.com/wiremock/python-wiremock/issues/74 WireMock can run in unit tests, as a standalone process or a container. Key features include: +- [Testcontainers Python](https://github.com/testcontainers/testcontainers-python) module to easily start WireMock server for your tests +- REST API Client for a standalone WireMock Java server - Supports most of the major [Wiremock](https://wiremock.org/docs) features (more on their way soon) -- Support for [testcontainers-python](https://github.com/testcontainers/testcontainers-python) to easily start wiremock server for your tests -- Support for standalone wiremock JAVA sever -## Install as Dependency +## References -To install: - - `pip install wiremock` - -To install with testing dependencies: - - `pip install wiremock[testing]` - -To install via Poetry: - - `poetry add --extras=testing wiremock` - -## Quick Start - -The preferred way of using WireMock to mock your services is by using the provided `WireMockContainer` [testcontainers-python](https://github.com/testcontainers/testcontainers-python). - -```python -import pytest - -from wiremock.testing.testcontainer import wiremock_container - -@pytest.fixture(scope="session") # (1) -def wm_server(): - with wiremock_container(secure=False) as wm: - - Config.base_url = wm.get_url("__admin") # (2) - - Mappings.create_mapping( - Mapping( - request=MappingRequest(method=HttpMethods.GET, url="/hello"), - response=MappingResponse(status=200, body="hello"), - persistent=False, - ) - ) # (3) - yield wm - - -def test_get_hello_world(wm_server): # (4) - - resp1 = requests.get(wm_server.get_url("/hello"), verify=False) - - assert resp1.status_code == 200 - assert resp1.content == b"hello" -``` - -1. Create a pytest fixture to manage the container life-cycle. use fixture `scope` to control how often the container is created - -2. Set the wiremock sdk config url to the url exposed by the container - -3. Create response and request mappings using the Admin SDK. - -4. Use the `wm_server` fixture in your tests and make requests against the mock server. - -You can read more about Testcontainers support in python-wiremock [here](docs/testcontainers.md). +- [Quickstart Guide](./docs/quickstart) +- [Installation](./docs/install) +- [Full documentation](http://wiremock.readthedocs.org/) ## Examples @@ -87,24 +37,6 @@ There are several example projects included to demonstrate the different ways th services in your tests and systems. The example test modules demonstrate different strategies for testing against the same "product service" and act as a good demonstration of real world applications to help you get started. -- [Python Testcontainers](example/tests/test_testcontainers.py) +- [Testcontainers Python](example/tests/test_testcontainers.py) - [Standalone Java Server Version](example/tests/test_java_server.py) - -## Documentation - -wiremock documentation can be found at http://wiremock.readthedocs.org/ - -## Pull Requests - -General Rules: - -- All Tests must pass -- Coverage shouldn't decrease -- All Pull Requests should be rebased against master **before** submitting the PR. - -## Development - -Setup the project using poetry. - -`poetry install` diff --git a/docs/api-client.md b/docs/api-client.md new file mode 100644 index 0000000..dedc06e --- /dev/null +++ b/docs/api-client.md @@ -0,0 +1,73 @@ +Using with a Standalone WireMock +=========== + +An example app: + +```python +from wiremock.constants import Config +from wiremock.client import * + +Config.base_url = 'https://mockserver.example.com/__admin/' +# Optionally set a custom cert path: +# Config.requests_cert = ... (See requests documentation) +# Optionally disable cert verification +# Config.requests_verify = False + +mapping = Mapping( + priority=100, + request=MappingRequest( + method=HttpMethods.GET, + url='/hello' + ), + response=MappingResponse( + status=200, + body='hi' + ), + persistent=False, +) + +mapping = Mappings.create_mapping(mapping=mapping) + +all_mappings = Mappings.retrieve_all_mappings() +``` + +### Starting WireMock server with a context manager + +```python +from wiremock.constants import Config +from wiremock.client import * +from wiremock.server.server import WireMockServer + +with WireMockServer() as wm: + Config.base_url = 'http://localhost:{}/__admin'.format(wm.port) + Mappings.create_mapping(...) # Set up stubs + requests.get(...) # Make API calls +``` + +### Starting WireMock server in a unittest.TestCase + +```python + +class MyTestClassBase(TestCase): + @classmethod + def setUpClass(cls): + wm = self.wiremock_server = WireMockServer() + wm.start() + Config.base_url = 'http://localhost:{}/__admin'.format(wm.port) + + @classmethod + def tearDownClass(cls): + self.wiremock_server.stop() +``` + +### Customizing the path to java + +```python +WireMockServer(java_path='/path/to/my/java') +``` + +### Customizing the WireMock server JAR file: + +```python +WireMockServer(jar_path='/my/secret/location/wiremock-standalone-2.35.0.jar') +``` diff --git a/docs/changelog.md b/docs/changelog.md index 000b691..e0bafed 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,11 @@ ChangeLog Changes to the library are recorded here. +Newer version +------ + +See [GitHub Releases](https://github.com/wiremock/python-wiremock/releases) + v2.4.0 ------ diff --git a/docs/index.md b/docs/index.md index 9bf11e8..9fb7260 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,38 +1,34 @@ -Python client for WireMock standalone Admin API -===== +# Python WireMock -This library provides a HTTP client to the WireMock standalone server's -admin API. +Python WireMock is an HTTP client that allows users to interact with a WireMock instance from within a Python project. -Links -===== +[![a](https://img.shields.io/badge/slack-%23wiremock%2Fpython-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) -- WireMock Standalone: -- Documentation: -- Official Repository: - -- Package: TODO +## Key Features -Requirements -============ +WireMock can run in unit tests, as a standalone process or a container, or in the cloud. +Python WireMock enables all these usage modes. +Key features include: -wiremock is known to support Python 3.7. +- [Testcontainers Python](https://github.com/testcontainers/testcontainers-python) module to easily start WireMock server for your tests +- REST API Client for a standalone WireMock Java server +- Supports most of the major [Wiremock](https://wiremock.org/docs) features (more on their way soon) -Download -======== +## Documentation -PyPI: TODO +- [Quickstart](./quickstart) +- [Installation](./install) +- [Testconatiners module](./testcontainers) +- [Using with standalone WireMock](./api-client) -```bash -$ pip install wiremock -``` +## Links -Source: +- WireMock Standalone: +- Documentation: +- Official Repository: +- Package: -```bash -$ git clone TODO -$ poetry install -``` +LY{xefVN zjJfX=4%*j()l$F>s5mrNy-%ZpG5x!%nJwQdx@vdssiyvTujr<|te2WHt5yVQpXsfp zyocnP@~szptD(Uzybi|}YPQoN=63|bD~u5FmK5;DxL*$){ezECpE9Bjx1d{}v8FQY6U%l?9geHvdcMRYo#8_!i+Eq! zsi(B1;hzEBohm{DDg84n37H{MeJJAA0zK|e!@of4^IQ=Rpu}Huaaz3x0u~oBe9NLb z9Q)?jqWti$z~}xd;_b=j8$8|H9Jv)Se9G^2c&PU7jdheY?(5FQS8X&4Jr~@Qmg2s zee3cMxYZ5^We4q>*Zv=PkFuS1<;@@9R#bQ#bLgI0xOQ?*@()aGmC8mw;_7<=lUSAg zgM=IPio?tIB!MySiOiOCMo`S0Q626etE?A{8Bw8TM!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ub#4^zd47BU*O~%dXEqKz)-dl7IoV z{D^{EUuQ@Y+VByz+29r7TJy z2*QyDeTK}0LWV>OopAa1XRLy+c`8eDq7o0l?k^}!rwRr)p@gq^F;;v*o_{L2VBfDO zO~zY^-CZ#GC~|fEYSF8CptoSEkQztY zYVpm-+La-#cetuTgeC4W?p~h~gB|fI55ckpL&f$tAZOnaTk@HW8J{>c9Ni65?=-l02T$^r#dkl=;$OpMsU2z>+sWd!h`cH4pQw}J>>YB`tkb zLo(1qT`d)fMzkRk^($Vv>o8s;OMl!u$D|kQtITN7_>y{jZ{RaM>19|KZtZgil%t_S71q+G^!UhzV-^ zeS%D;_B`q-$`l#?lc-Ufsb^$T-%OBye{>v@?h)5`IuD`xQXL$3vjpe#O_A+o?7sOf z3{;;QnyI=8o;M}bh5j&uoGCgGCKqCX%6Z9x@8MR!EuA$Nrd4`urJOdi}9NmW4js91mQI*fIRB~cy zeGuQOIPu=I!j@9&!?IiGB^7W>3i4%+j6Dy2s6O5DiXR@GWNTN|(J>@^tOiy^kYm+DdQ z1bjpid$DU)Dl_3%eQMPJ#m%;5o}nge?NsfBCsv#@%?{3cz>X71cIbT&yoRS~S&GFZ zdz2#CO+xJW*3fAzVRXgEz2uD8kD0QN62jppveGkk4Ajaf+0yF0G4oLcO zfC$HpD7E2X%y*h#m_jbg?5;~R>;ZsX3`H>c}SmNN(eH`OClWqfKu~H;P2~M~% zr-5p$_Kk_9bh`O5Tz>vbsV~OQlW|7Uz{&#LdnE5}{)N!c* diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 3519250..68bd315 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -33,7 +33,7 @@ class WireMockContainer(DockerContainer): def __init__( self, - image: str = "wiremock/wiremock:2.35.0", + image: str = "wiremock/wiremock:2.35.1", http_server_port: int = 8080, https_server_port: int = 8443, secure: bool = True, @@ -227,7 +227,7 @@ def start(self, cmd: Optional[str] = None) -> "WireMockContainer": @contextmanager def wiremock_container( - image: str = "wiremock/wiremock:2.35.0", + image: str = "wiremock/wiremock:2.35.1", http_server_port: int = 8080, https_server_port: int = 8443, secure: bool = True, From f5b11d2dba6e99d885a8f3b59d6bd9d244f61d8f Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Wed, 6 Sep 2023 17:13:46 +0200 Subject: [PATCH 20/52] Use Poetry 1.5.1 via GitHub action in the pipeline Should work around https://github.com/snok/install-poetry/issues/131 --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a43f079..9fedd6c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,8 +21,10 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Poetry - run: curl -sSL https://install.python-poetry.org | python + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.1 - name: Install dependencies run: | From 88962c23c2274b8fb338932733601f51d7b71848 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Wed, 6 Sep 2023 17:16:52 +0200 Subject: [PATCH 21/52] Pin Poetry in Release and Linter pipelines --- .github/workflows/lint-docs.yml | 6 ++++-- .github/workflows/release.yml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-docs.yml b/.github/workflows/lint-docs.yml index 5289e85..eb5be6d 100644 --- a/.github/workflows/lint-docs.yml +++ b/.github/workflows/lint-docs.yml @@ -16,8 +16,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" - - name: Install Poetry - run: curl -sSL https://install.python-poetry.org | python + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.1 - name: Install dependencies run: | poetry env use '3.10' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b951c92..a56212a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" - - name: Install Poetry - run: curl -sSL https://install.python-poetry.org | python + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.1 - name: Install dependencies run: poetry install - name: Build distributions From 52cb5b1d5417b2b27399bf987ff947ab800c2df7 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Wed, 6 Sep 2023 17:17:26 +0200 Subject: [PATCH 22/52] Fix Docker images for Testcontainers tests --- wiremock/testing/testcontainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 68bd315..2f64cda 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -33,7 +33,7 @@ class WireMockContainer(DockerContainer): def __init__( self, - image: str = "wiremock/wiremock:2.35.1", + image: str = "wiremock/wiremock:2.35.1-1", http_server_port: int = 8080, https_server_port: int = 8443, secure: bool = True, @@ -227,7 +227,7 @@ def start(self, cmd: Optional[str] = None) -> "WireMockContainer": @contextmanager def wiremock_container( - image: str = "wiremock/wiremock:2.35.1", + image: str = "wiremock/wiremock:2.35.1-1", http_server_port: int = 8080, https_server_port: int = 8443, secure: bool = True, From 3ebdd326b5e946013899c141f657e8294dce0de8 Mon Sep 17 00:00:00 2001 From: Hasso Mehide Date: Thu, 2 Nov 2023 23:29:21 +0200 Subject: [PATCH 23/52] Map the response of create_mapping to Mapping, instead of MappingResponse which despite its name is not the correct type --- .../test_mapping/test_mapping_resource.py | 20 ++++++++++--------- wiremock/resources/mappings/resource.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_resources/test_mapping/test_mapping_resource.py b/tests/test_resources/test_mapping/test_mapping_resource.py index 2bf21c5..b491859 100644 --- a/tests/test_resources/test_mapping/test_mapping_resource.py +++ b/tests/test_resources/test_mapping/test_mapping_resource.py @@ -16,22 +16,24 @@ @pytest.mark.resource @responses.activate def test_create_mapping(): - e = MappingResponse(body="test", status=200) - resp = e.get_json_data() - responses.add( - responses.POST, "http://localhost/__admin/mappings", json=resp, status=200 - ) - m = Mapping( priority=1, request=MappingRequest(url="test", method="GET"), response=MappingResponse(status=200, body="test"), ) + e = Mapping(**m, id="1234-5678") + resp = e.get_json_data() + responses.add( + responses.POST, "http://localhost/__admin/mappings", json=resp, status=200 + ) + r = Mappings.create_mapping(m) - assert isinstance(r, MappingResponse) - assert r.status == 200 - assert r.body == "test" + assert isinstance(r, Mapping) + assert r.id == "1234-5678" + assert r.priority == 1 + assert r.request == m.request + assert r.response == m.response @pytest.mark.unit diff --git a/wiremock/resources/mappings/resource.py b/wiremock/resources/mappings/resource.py index 70ff060..83501ba 100644 --- a/wiremock/resources/mappings/resource.py +++ b/wiremock/resources/mappings/resource.py @@ -30,7 +30,7 @@ def create_mapping(cls, mapping, parameters={}): params=parameters, ) response = cls.REST_CLIENT.handle_response(response) - return MappingResponse.from_dict(response.json()) + return Mapping.from_dict(response.json()) @classmethod def retrieve_all_mappings(cls, parameters={}): From 9451b2f0c9d6d46d75c4b285eb98142e198a3e49 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 15 Nov 2023 12:31:53 +0000 Subject: [PATCH 24/52] fixed command arg for --root-dir in standalone server --- wiremock/server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiremock/server/server.py b/wiremock/server/server.py index 88b39aa..b330f0c 100644 --- a/wiremock/server/server.py +++ b/wiremock/server/server.py @@ -61,7 +61,7 @@ def start(self): "--local-response-templating", ] if self.root_dir is not None: - cmd.append("--root-dir=") + cmd.append("--root-dir") cmd.append(str(self.root_dir)) try: self.__subprocess = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) From d7cb44af3c3cf84e84b219094b3fc97a8ed06c5c Mon Sep 17 00:00:00 2001 From: mhairifin Date: Fri, 9 Aug 2024 15:31:41 +0100 Subject: [PATCH 25/52] replace Path with PosixPath to fix Windows compatibility --- poetry.lock | 71 ++++++------------------------- wiremock/testing/testcontainer.py | 6 +-- 2 files changed, 16 insertions(+), 61 deletions(-) diff --git a/poetry.lock b/poetry.lock index ef20ef5..34e7a3f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "black" version = "23.3.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -55,7 +54,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "cachetools" version = "5.3.0" description = "Extensible memoizing collections and decorators" -category = "dev" optional = false python-versions = "~=3.7" files = [ @@ -67,7 +65,6 @@ files = [ name = "certifi" version = "2022.12.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -79,7 +76,6 @@ files = [ name = "chardet" version = "5.1.0" description = "Universal encoding detector for Python 3" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -91,7 +87,6 @@ files = [ name = "charset-normalizer" version = "3.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -176,7 +171,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -192,7 +186,6 @@ importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -204,7 +197,6 @@ files = [ name = "coverage" version = "7.2.3" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -271,7 +263,6 @@ toml = ["tomli"] name = "deprecation" version = "2.1.0" description = "A library to handle automated deprecations" -category = "main" optional = true python-versions = "*" files = [ @@ -286,7 +277,6 @@ packaging = "*" name = "distlib" version = "0.3.6" description = "Distribution utilities" -category = "dev" optional = false python-versions = "*" files = [ @@ -298,7 +288,6 @@ files = [ name = "docker" version = "6.1.0" description = "A Python library for the Docker Engine API." -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -320,7 +309,6 @@ ssh = ["paramiko (>=2.4.3)"] name = "exceptiongroup" version = "1.1.1" description = "Backport of PEP 654 (exception groups)" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -335,7 +323,6 @@ test = ["pytest (>=6)"] name = "filelock" version = "3.12.0" description = "A platform independent file lock." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -351,7 +338,6 @@ testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "p name = "ghp-import" version = "2.1.0" description = "Copy your docs directly to the gh-pages branch." -category = "dev" optional = false python-versions = "*" files = [ @@ -369,7 +355,6 @@ dev = ["flake8", "markdown", "twine", "wheel"] name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -381,7 +366,6 @@ files = [ name = "importlib-metadata" version = "6.5.1" description = "Read metadata from Python packages" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -402,7 +386,6 @@ testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packag name = "importlib-resources" version = "5.12.0" description = "Read resources from Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -421,7 +404,6 @@ testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-chec name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -433,7 +415,6 @@ files = [ name = "jinja2" version = "3.1.2" description = "A very fast and expressive template engine." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -451,7 +432,6 @@ i18n = ["Babel (>=2.7)"] name = "markdown" version = "3.3.7" description = "Python implementation of Markdown." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -469,7 +449,6 @@ testing = ["coverage", "pyyaml"] name = "markdown-include" version = "0.8.1" description = "A Python-Markdown extension which provides an 'include' function" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -487,7 +466,6 @@ tests = ["pytest"] name = "markupsafe" version = "2.1.3" description = "Safely add untrusted strings to HTML/XML markup." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -511,6 +489,16 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -547,7 +535,6 @@ files = [ name = "mergedeep" version = "1.3.4" description = "A deep merge function for 🐍." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -559,7 +546,6 @@ files = [ name = "mkdocs" version = "1.4.3" description = "Project documentation with Markdown." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -589,7 +575,6 @@ min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-imp name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -601,7 +586,6 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -613,7 +597,6 @@ files = [ name = "pathspec" version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -625,7 +608,6 @@ files = [ name = "platformdirs" version = "3.2.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -644,7 +626,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.2.2)", "pytest- name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -663,7 +644,6 @@ testing = ["pytest", "pytest-benchmark"] name = "pyproject-api" version = "1.5.1" description = "API to interact with the python pyproject.toml based projects" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -683,7 +663,6 @@ testing = ["covdefaults (>=2.2.2)", "importlib-metadata (>=6)", "pytest (>=7.2.1 name = "pytest" version = "7.3.1" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -707,7 +686,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "pytest-cov" version = "4.0.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -726,7 +704,6 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtuale name = "pytest-cover" version = "3.0.0" description = "Pytest plugin for measuring coverage. Forked from `pytest-cov`." -category = "dev" optional = false python-versions = "*" files = [ @@ -741,7 +718,6 @@ pytest-cov = ">=2.0" name = "pytest-coverage" version = "0.0" description = "Pytest plugin for measuring coverage. Forked from `pytest-cov`." -category = "dev" optional = false python-versions = "*" files = [ @@ -756,7 +732,6 @@ pytest-cover = "*" name = "python-coveralls" version = "2.9.3" description = "Python interface to coveralls.io API\n" -category = "dev" optional = false python-versions = "*" files = [ @@ -774,7 +749,6 @@ six = "*" name = "python-dateutil" version = "2.8.2" description = "Extensions to the standard Python datetime module" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -789,7 +763,6 @@ six = ">=1.5" name = "pywin32" version = "306" description = "Python for Window Extensions" -category = "main" optional = true python-versions = "*" files = [ @@ -813,7 +786,6 @@ files = [ name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -863,7 +835,6 @@ files = [ name = "pyyaml-env-tag" version = "0.1" description = "A custom YAML tag for referencing environment variables in YAML files. " -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -878,7 +849,6 @@ pyyaml = "*" name = "requests" version = "2.28.2" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7, <4" files = [ @@ -900,7 +870,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "responses" version = "0.23.1" description = "A utility library for mocking out the `requests` Python library." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -922,7 +891,6 @@ tests = ["coverage (>=6.0.0)", "flake8", "mypy", "pytest (>=7.0.0)", "pytest-asy name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -934,7 +902,6 @@ files = [ name = "testcontainers" version = "3.7.1" description = "Library provides lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container" -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -968,7 +935,6 @@ selenium = ["selenium"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -980,7 +946,6 @@ files = [ name = "tox" version = "4.4.12" description = "tox is a generic virtualenv management and test command line tool" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1010,7 +975,6 @@ testing = ["build[virtualenv] (>=0.10)", "covdefaults (>=2.3)", "devpi-process ( name = "typed-ast" version = "1.5.4" description = "a fork of Python 2 and 3 ast modules with type comment support" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1044,7 +1008,6 @@ files = [ name = "types-pyyaml" version = "6.0.12.9" description = "Typing stubs for PyYAML" -category = "dev" optional = false python-versions = "*" files = [ @@ -1056,7 +1019,6 @@ files = [ name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1068,7 +1030,6 @@ files = [ name = "urllib3" version = "1.26.15" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ @@ -1085,7 +1046,6 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] name = "virtualenv" version = "20.22.0" description = "Virtual Python Environment builder" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1107,7 +1067,6 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "coverage-enable-subprocess name = "watchdog" version = "3.0.0" description = "Filesystem events monitoring" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1147,7 +1106,6 @@ watchmedo = ["PyYAML (>=3.10)"] name = "websocket-client" version = "1.5.1" description = "WebSocket client for Python with low level API options" -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -1164,7 +1122,6 @@ test = ["websockets"] name = "wheel" version = "0.40.0" description = "A built-package format for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1179,7 +1136,6 @@ test = ["pytest (>=6.0.0)"] name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "main" optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -1264,7 +1220,6 @@ files = [ name = "zipp" version = "3.15.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1281,5 +1236,5 @@ testing = ["docker", "testcontainers"] [metadata] lock-version = "2.0" -python-versions = "^3.7 | ^3.8 | ^3.9 | ^3.10 | ^3.11" -content-hash = "5b762b85c489532b28b3e77cede06094b97478e2ffbdbc33010b9c39c2a931d4" +python-versions = "^3.7 | ^3.8 | ^3.9 | ^3.10 | ^3.11" +content-hash = "797379f6dd32687c935a7603dfaca39832b6748e8823d4402922ad7a94329851" diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 2f64cda..80c4665 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -4,7 +4,7 @@ import tempfile import time from contextlib import contextmanager -from pathlib import Path +from pathlib import Path, PurePosixPath from typing import Any, Dict, Generator, List, Optional, Tuple, Union from urllib.parse import urljoin @@ -131,7 +131,7 @@ def copy_mappings_to_container(self) -> None: """ self.copy_files_to_container( - configs=self.mapping_stubs, container_dir_path=Path(f"{self.MAPPINGS_DIR}") + configs=self.mapping_stubs, container_dir_path=PurePosixPath(f"{self.MAPPINGS_DIR}") ) def copy_mapping_files_to_container(self) -> None: @@ -140,7 +140,7 @@ def copy_mapping_files_to_container(self) -> None: the configured FILES_DIR """ self.copy_files_to_container( - configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}") + configs=self.mapping_files, container_dir_path=PurePosixPath(f"{self.FILES_DIR}") ) def server_running(self, retry_count: int = 3, retry_delay: int = 1) -> bool: From b13d214cbe0a0f2c5c00f4bac30f4eb7451c6f0a Mon Sep 17 00:00:00 2001 From: mhairifin Date: Tue, 13 Aug 2024 09:35:12 +0100 Subject: [PATCH 26/52] Convert to posix path at point of write --- wiremock/testing/testcontainer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 80c4665..518113f 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -4,7 +4,7 @@ import tempfile import time from contextlib import contextmanager -from pathlib import Path, PurePosixPath +from pathlib import Path from typing import Any, Dict, Generator, List, Optional, Tuple, Union from urllib.parse import urljoin @@ -94,7 +94,7 @@ def with_command(self, cmd: Optional[str] = None) -> "WireMockContainer": def copy_file_to_container(self, host_path: Path, container_path: Path) -> None: with open(host_path, "rb") as fp: self.get_wrapped_container().put_archive( - path=container_path, data=fp.read() + path=container_path.as_posix(), data=fp.read() ) def copy_files_to_container( @@ -131,7 +131,7 @@ def copy_mappings_to_container(self) -> None: """ self.copy_files_to_container( - configs=self.mapping_stubs, container_dir_path=PurePosixPath(f"{self.MAPPINGS_DIR}") + configs=self.mapping_stubs, container_dir_path=Path(f"{self.MAPPINGS_DIR}") ) def copy_mapping_files_to_container(self) -> None: @@ -140,7 +140,7 @@ def copy_mapping_files_to_container(self) -> None: the configured FILES_DIR """ self.copy_files_to_container( - configs=self.mapping_files, container_dir_path=PurePosixPath(f"{self.FILES_DIR}") + configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}") ) def server_running(self, retry_count: int = 3, retry_delay: int = 1) -> bool: From fc2df60d0ff13e22f2cf5995d11596f83869a0ea Mon Sep 17 00:00:00 2001 From: mhairifin Date: Tue, 13 Aug 2024 09:35:34 +0100 Subject: [PATCH 27/52] test to ensure container write path is posix formatted --- tests/test_containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_containers.py b/tests/test_containers.py index cf3c193..cbcde56 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -321,7 +321,7 @@ def test_copy_file_to_container(mock_get_container: Mock, tmp_path: Path): # Assert mock_get_container.return_value.put_archive.assert_called_once_with( - path=Path(wm.MAPPINGS_DIR), data=b'{"foo": "bar"}' + path=Path(wm.MAPPINGS_DIR).as_posix(), data=b'{"foo": "bar"}' ) From 67be2d2c3881c3b0a5454ffe902d67340a686403 Mon Sep 17 00:00:00 2001 From: Alexandru Jircan Date: Mon, 16 Dec 2024 11:57:20 +0200 Subject: [PATCH 28/52] Fix `Requests.reset_request_journal()` for Wiremock V3 --- tests/test_resources/test_requests/test_requests_resource.py | 2 +- wiremock/resources/requests/resource.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_resources/test_requests/test_requests_resource.py b/tests/test_resources/test_requests/test_requests_resource.py index 1b22623..6e537f9 100644 --- a/tests/test_resources/test_requests/test_requests_resource.py +++ b/tests/test_resources/test_requests/test_requests_resource.py @@ -58,7 +58,7 @@ def test_get_request(): @responses.activate def test_reset_request_journal(): responses.add( - responses.POST, "http://localhost/__admin/requests/reset", body="", status=200 + responses.DELETE, "http://localhost/__admin/requests", body="", status=200 ) r = Requests.reset_request_journal() diff --git a/wiremock/resources/requests/resource.py b/wiremock/resources/requests/resource.py index 8486d23..75a3b73 100644 --- a/wiremock/resources/requests/resource.py +++ b/wiremock/resources/requests/resource.py @@ -47,7 +47,7 @@ def get_request(cls, request_id, parameters={}): @classmethod def reset_request_journal(cls, parameters={}): ids = {"id": "reset"} - response = cls.REST_CLIENT.post(cls.get_base_uri(cls.endpoint_single(), **ids), headers=make_headers(), params=parameters) + response = cls.REST_CLIENT.delete(cls.get_base_uri(cls.endpoint()), headers=make_headers(), params=parameters) return cls.REST_CLIENT.handle_response(response) @classmethod From 141a39bd66ebb398529d5ebfd234fb4e796b8614 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 16 Dec 2024 14:00:45 +0000 Subject: [PATCH 29/52] Update the docker compose command for the integration tests Github no longer support the `docker-compose` command. They have moved to the `docker compose` version instead --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9fedd6c..d159542 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,5 +45,5 @@ jobs: - name: Integration Tests run: | cd examples/ - docker-compose build overview_srv - docker-compose run overview_srv pytest --tb=short + docker compose build overview_srv + docker compose run overview_srv pytest --tb=short From d03b1bb6a3ccb1a87c4f817a4b3ca10ff1b78361 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 16 Dec 2024 18:08:40 +0000 Subject: [PATCH 30/52] Fix the directory referenced in the integration-tests job Also fixed the context in the examples docker file --- .github/workflows/tests.yml | 2 +- examples/intro/docker-compose.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d159542..5b8c143 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,6 +44,6 @@ jobs: - name: Integration Tests run: | - cd examples/ + cd examples/intro/ docker compose build overview_srv docker compose run overview_srv pytest --tb=short diff --git a/examples/intro/docker-compose.yml b/examples/intro/docker-compose.yml index 5637014..ba27f19 100644 --- a/examples/intro/docker-compose.yml +++ b/examples/intro/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" services: overview_srv: build: - context: ../ + context: ../../ dockerfile: examples/intro/Dockerfile ports: - "5001:5001" @@ -19,7 +19,7 @@ services: products_srv: build: - context: ../ + context: ../../ dockerfile: examples/intro/Dockerfile ports: - "5002:5002" From 664e55c10c424bef756e4748ca67be7c9a017c18 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 16 Dec 2024 18:27:24 +0000 Subject: [PATCH 31/52] fix docker compose command in the docs --- examples/intro/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/intro/README.md b/examples/intro/README.md index 9ff6ae2..cdc054a 100644 --- a/examples/intro/README.md +++ b/examples/intro/README.md @@ -42,7 +42,7 @@ to allow us to write solid integration tests that dont involved mockig the code To run the tests use docker-compose to create the necessary containers. -`docker-compose run overview_srv pytest --tb=short` +`docker compose run overview_srv pytest --tb=short` ## How we use this example code base From 9205c8e3e507b445209db6330f29891bf5d15e26 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 16 Dec 2024 21:13:06 +0000 Subject: [PATCH 32/52] Update volume paths in docker-compose.yml for consistency --- examples/intro/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/intro/docker-compose.yml b/examples/intro/docker-compose.yml index ba27f19..6d63829 100644 --- a/examples/intro/docker-compose.yml +++ b/examples/intro/docker-compose.yml @@ -13,7 +13,7 @@ services: - "host.docker.internal:host-gateway" volumes: - /var/run/docker.sock:/var/run/docker.sock - - ..:/app/ + - ../../app/ - .:/app/example/ command: uvicorn product_mock.overview_service:app --host=0.0.0.0 --port=5001 @@ -24,6 +24,6 @@ services: ports: - "5002:5002" volumes: - - ..:/app/ + - ../../:/app/ - .:/app/example/ command: uvicorn product_mock.products_service:app --host=0.0.0.0 --port=5002 From d42725c15e1322da496c154a7121dd82f9332228 Mon Sep 17 00:00:00 2001 From: Lee Turner Date: Mon, 16 Dec 2024 22:10:43 +0000 Subject: [PATCH 33/52] Update examples/intro/docker-compose.yml Co-authored-by: Alexandru Jircan --- examples/intro/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/intro/docker-compose.yml b/examples/intro/docker-compose.yml index 6d63829..0192c5e 100644 --- a/examples/intro/docker-compose.yml +++ b/examples/intro/docker-compose.yml @@ -13,7 +13,7 @@ services: - "host.docker.internal:host-gateway" volumes: - /var/run/docker.sock:/var/run/docker.sock - - ../../app/ + - ../../:/app/ - .:/app/example/ command: uvicorn product_mock.overview_service:app --host=0.0.0.0 --port=5001 From 650c0b83d6ee1cbd1b2672da6fe65dd5ac9c8abf Mon Sep 17 00:00:00 2001 From: jonassvalin Date: Tue, 7 Jan 2025 16:22:50 +0100 Subject: [PATCH 34/52] Increase retry_count for server_running to 10 --- wiremock/testing/testcontainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 518113f..b9580a1 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -143,7 +143,7 @@ def copy_mapping_files_to_container(self) -> None: configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}") ) - def server_running(self, retry_count: int = 3, retry_delay: int = 1) -> bool: + def server_running(self, retry_count: int = 10, retry_delay: int = 1) -> bool: """Pings the __admin/mappings endpoint of the wiremock server running inside the container as a proxy for checking if the server is up and running. From 18ed81cc93078324f5d1b0972e80db62f066050a Mon Sep 17 00:00:00 2001 From: Tom Akehurst Date: Thu, 10 Jul 2025 16:54:47 +0100 Subject: [PATCH 35/52] Added WireMock Cloud callout --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f2d2747..7e12ce1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,19 @@

+--- + + + + + +
+WireMock Cloud Logo +WireMock open source is supported by WireMock Cloud. Please consider trying it out if your team needs advanced capabilities such as OpenAPI, dynamic state, data sources and more. +
+ +--- + Python WireMock is a library that allows users to interact with a WireMock instance from within a Python project. Full documentation can be found at [wiremock.readthedocs.org](http://wiremock.readthedocs.org/). From 1bc6bb0c12f6afdcc32eac034ed0ea61c465f3f0 Mon Sep 17 00:00:00 2001 From: Tom Akehurst Date: Thu, 10 Jul 2025 17:14:11 +0100 Subject: [PATCH 36/52] Updated callout link URL in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e12ce1..e495272 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ WireMock Cloud Logo -WireMock open source is supported by WireMock Cloud. Please consider trying it out if your team needs advanced capabilities such as OpenAPI, dynamic state, data sources and more. +WireMock open source is supported by WireMock Cloud. Please consider trying it out if your team needs advanced capabilities such as OpenAPI, dynamic state, data sources and more. From a663c022a55e31e1d899d6a9af3f9cd361f1f213 Mon Sep 17 00:00:00 2001 From: Alex Jrk Date: Fri, 18 Jul 2025 15:21:28 +0300 Subject: [PATCH 37/52] fix tests --- .github/workflows/tests.yml | 4 ++-- examples/intro/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5b8c143..5cf0d42 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: jobs: unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/examples/intro/Dockerfile b/examples/intro/Dockerfile index b5e68d9..b06aa66 100644 --- a/examples/intro/Dockerfile +++ b/examples/intro/Dockerfile @@ -1,5 +1,5 @@ # vim: set filetype=Dockerfile: -FROM python:3.11-slim-buster +FROM python:3.11-slim-bookworm ENV POETRY_HOME="/opt/poetry" \ POETRY_VIRTUALENVS_CREATE=false \ From 9720a89f5ab6d025bae03a71ce2d0c3e855f6b0c Mon Sep 17 00:00:00 2001 From: Alex Jrk Date: Fri, 18 Jul 2025 15:23:41 +0300 Subject: [PATCH 38/52] revert v3 changes --- tests/test_resources/test_requests/test_requests_resource.py | 2 +- wiremock/resources/requests/resource.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_resources/test_requests/test_requests_resource.py b/tests/test_resources/test_requests/test_requests_resource.py index 6e537f9..1b22623 100644 --- a/tests/test_resources/test_requests/test_requests_resource.py +++ b/tests/test_resources/test_requests/test_requests_resource.py @@ -58,7 +58,7 @@ def test_get_request(): @responses.activate def test_reset_request_journal(): responses.add( - responses.DELETE, "http://localhost/__admin/requests", body="", status=200 + responses.POST, "http://localhost/__admin/requests/reset", body="", status=200 ) r = Requests.reset_request_journal() diff --git a/wiremock/resources/requests/resource.py b/wiremock/resources/requests/resource.py index 75a3b73..8486d23 100644 --- a/wiremock/resources/requests/resource.py +++ b/wiremock/resources/requests/resource.py @@ -47,7 +47,7 @@ def get_request(cls, request_id, parameters={}): @classmethod def reset_request_journal(cls, parameters={}): ids = {"id": "reset"} - response = cls.REST_CLIENT.delete(cls.get_base_uri(cls.endpoint()), headers=make_headers(), params=parameters) + response = cls.REST_CLIENT.post(cls.get_base_uri(cls.endpoint_single(), **ids), headers=make_headers(), params=parameters) return cls.REST_CLIENT.handle_response(response) @classmethod From 0576d4103805c47781e76ba3588950f25b8b56bb Mon Sep 17 00:00:00 2001 From: Alex Jrk Date: Sun, 20 Jul 2025 14:28:49 +0300 Subject: [PATCH 39/52] Delete unused requirements --- requirements.pip | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 requirements.pip diff --git a/requirements.pip b/requirements.pip deleted file mode 100644 index f1443e1..0000000 --- a/requirements.pip +++ /dev/null @@ -1,17 +0,0 @@ -black==19.10b0 -coverage==5.0.3 -docutils==0.16 -mock==4.0.1 -nose==1.3.7 -python-coveralls==2.9.3 -requests==2.23.0 -responses==0.10.9 -Sphinx==2.4.3 -sphinx-rtd-theme==0.4.3 -toml==0.10.0 -tox==3.14.5 -twine==3.1.1 -virtualenv==20.0.5 -watchdog==0.10.2 -mkdocs==1.3.0 -markdown_include==0.8.1 From c0cc50f88509198b2a9cdeb882bf0197199e2843 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 28 Jul 2025 11:22:21 +0100 Subject: [PATCH 40/52] Update version in preparation for new release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 103d39b..3e5a83f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wiremock" -version = "2.6.1" +version = "2.7.0" description = "Wiremock Admin API Client" authors = ["Cody Lee ", "Mike Waites "] license = "OSI Approved :: Apache Software License" From 25d82c44c15f7c319f4f8f04c498aedc89cb5e02 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 28 Jul 2025 13:20:13 +0100 Subject: [PATCH 41/52] Add release documentation and update docs link in the readme --- README.md | 2 +- RELEASING.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 RELEASING.md diff --git a/README.md b/README.md index e495272..c7fae0f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ --- Python WireMock is a library that allows users to interact with a WireMock instance from within a Python project. -Full documentation can be found at [wiremock.readthedocs.org](http://wiremock.readthedocs.org/). +Full documentation can be found at [wiremock.readthedocs.org](https://wiremock.readthedocs.org/). [![a](https://img.shields.io/badge/slack-%23wiremock%2Fpython-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) [![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](http://wiremock.readthedocs.org/) diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..f10f3cf --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,29 @@ +# Checklist for releasing WireMock + +- [ ] Bump version number +- [ ] Publish the release note +- [ ] Announce on the WireMock Community Slack +- [ ] Announce on social + +## Pre-release - bump version number +Make sure the version number has been updated. Do this by updating the version in `./pyproject.toml`: + +```toml +[tool.poetry] +name = "wiremock" +version = "2.7.0" +``` + +Commit and push the changes made. + +## Publish the release note +Release drafter should have created a draft release note called "next". Check it for sanity and edit it to add any +additional information and then set the tag to the version you have just added above. You can then publish the release. + +Publishing the release should trigger the release action to publish to PyPI + +## Post an announcement on the WireMock Community Slack +Announce in the #announcments channel then link to the message from #general. + +## Shout about it on as many social media platforms as possible +You know the drill. \ No newline at end of file From b9e2084e888d04a6d38eb66e85ca27c8f01e6375 Mon Sep 17 00:00:00 2001 From: leeturner Date: Mon, 28 Jul 2025 13:52:38 +0100 Subject: [PATCH 42/52] chore: missed a few links to the docs and update the title of the release docs --- README.md | 4 ++-- RELEASING.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c7fae0f..c20b6fa 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Python WireMock is a library that allows users to interact with a WireMock insta Full documentation can be found at [wiremock.readthedocs.org](https://wiremock.readthedocs.org/). [![a](https://img.shields.io/badge/slack-%23wiremock%2Fpython-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) -[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](http://wiremock.readthedocs.org/) +[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://wiremock.readthedocs.org/)