{"id":13595788,"url":"https://github.com/AndreyErmilov/pytest-mock-server","last_synced_at":"2025-04-09T13:33:28.401Z","repository":{"id":40277358,"uuid":"251575333","full_name":"AndreyErmilov/pytest-mock-server","owner":"AndreyErmilov","description":"Mock server plugin for pytest","archived":false,"fork":false,"pushed_at":"2022-05-17T02:57:53.000Z","size":27,"stargazers_count":27,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T22:38:22.630Z","etag":null,"topics":["mock-server","pytest","pytest-plugin","server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndreyErmilov.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-31T10:50:44.000Z","updated_at":"2023-10-01T15:57:18.000Z","dependencies_parsed_at":"2022-08-23T18:20:17.733Z","dependency_job_id":null,"html_url":"https://github.com/AndreyErmilov/pytest-mock-server","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreyErmilov%2Fpytest-mock-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreyErmilov%2Fpytest-mock-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreyErmilov%2Fpytest-mock-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreyErmilov%2Fpytest-mock-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndreyErmilov","download_url":"https://codeload.github.com/AndreyErmilov/pytest-mock-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223394746,"owners_count":17138608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mock-server","pytest","pytest-plugin","server"],"created_at":"2024-08-01T16:01:57.618Z","updated_at":"2024-11-06T18:31:36.001Z","avatar_url":"https://github.com/AndreyErmilov.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"==================\npytest-mock-server\n==================\n\n.. image:: https://img.shields.io/pypi/v/pytest-mock-server.svg\n    :target: https://pypi.org/project/pytest-mock-server\n    :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-mock-server.svg\n    :target: https://pypi.org/project/pytest-mock-server\n    :alt: Python versions\n\n.. image:: https://travis-ci.org/AndreyErmilov/pytest-mock-server.svg?branch=master\n    :target: https://travis-ci.org/AndreyErmilov/pytest-mock-server\n    :alt: See Build Status on Travis CI\n\n\nMock server plugin for pytest\n\n----\n\nInstallation\n------------\n\nYou can install \"pytest-mock-server\" via `pip`_ from `PyPI`_::\n\n    $ pip install pytest-mock-server\n\n\nUsage\n-----\nOne handler\n~~~~~~~~~~~\n.. code-block:: python\n\n  import pytest\n  import requests\n\n  @pytest.mark.server(url='/v1/books/', response=[{'id': 1}], method='GET')\n  def test_handler_responses():\n      response = requests.get('http://localhost:5000/v1/books/')\n      assert response.status_code == 200\n      assert response.json() == [{'id': 1}]\n\n\nMore than one handlers\n~~~~~~~~~~~~~~~~~~~~~~\n.. code-block:: python\n\n  import pytest\n  import requests\n\n  @pytest.mark.server(url='/v1/books/', response=[{'id': 1}], method='GET')\n  @pytest.mark.server(url='/v1/books/\u003cbook_id\u003e/', response={'id': 1}, method='GET')\n  def test_handler_responses():\n      response = requests.get('http://localhost:5000/v1/books/')\n      assert response.status_code == 200\n      assert response.json() == [{'id': 1}]\n      response = requests.get('http://localhost:5000/v1/books/1/')\n      assert response.status_code == 200\n      assert response.json() == {'id': 1}\n\n\nCallback executes before response returns\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n.. code-block:: python\n\n  import pytest\n  import requests\n  import time\n\n  def sleep_two(*args, **kwargs):\n      time.sleep(2)\n\n  @pytest.mark.server(url='/v1/books/', response={}, callback=sleep_two)\n  def test_handler_responses():\n      \"\"\"Ensures Timeouts works\"\"\"\n      with pytest.raises(requests.exceptions.Timeout):\n          response = requests.get('http://localhost:5000/v1/books/', timeout=1)\n\nCustom settings for server\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n.. code-block:: python\n\n  import pytest\n  import requests\n\n  @pytest.mark.server(url='/v1/books/', response={})\n  @pytest.mark.server_settings(port=8000)\n  def test_handler_responses():\n      response = requests.get('http://localhost:8000/v1/books/')\n      assert response.status_code == 200\n      assert response.json() == {}\n\n\nContributing\n------------\nContributions are very welcome. Tests can be run with `tox`_, please ensure\nthe coverage at least stays the same before you submit a pull request.\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, \"pytest-mock-server\" is free and open source software\n\n\nIssues\n------\n\nIf you encounter any problems, please `file an issue`_ along with a detailed description.\n\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`file an issue`: https://github.com/AndreyErmilov/pytest-mock-server/issues\n.. _`tox`: https://tox.readthedocs.io/en/latest/\n.. _`pip`: https://pypi.org/project/pip/\n.. _`PyPI`: https://pypi.org/project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndreyErmilov%2Fpytest-mock-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAndreyErmilov%2Fpytest-mock-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAndreyErmilov%2Fpytest-mock-server/lists"}