{"id":23135,"library":"openmock","title":"openmock - OpenSearch Mock for Python Testing","description":"A Python library for mocking OpenSearch (Elasticsearch) operations in unit tests. Provides a lightweight in-memory mock that simulates OpenSearch behaviors without needing a real cluster. Current version: 3.2.0, requires Python >=3.10. Release cadence irregular.","status":"active","version":"3.2.0","language":"python","source_language":"en","source_url":"https://github.com/vvanhaecke/openmock","tags":["opensearch","testing","mock","opensearchpy","python"],"install":[{"cmd":"pip install openmock","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"wrong":"from openmock import OpenMock","symbol":"FakeOpenSearch","correct":"from openmock import FakeOpenSearch"},{"wrong":"from openmock import OpenMock","symbol":"FakeAsyncOpenSearch","correct":"from openmock import AsyncFakeOpenSearch"},{"wrong":"from openmock import OpenMock","symbol":"patch","correct":"from openmock import patch"}],"quickstart":{"code":"from openmock import OpenMock\nfrom opensearchpy import OpenSearch\n\nwith OpenMock():\n    client = OpenSearch()\n    # index a document\n    client.index(index='my-index', body={'title': 'Test'})\n    # search\n    result = client.search(index='my-index', body={'query': {'match_all': {}}})\n    print(result['hits']['hits'][0]['_source']['title'])  # Output: Test","lang":"python","description":"Basic usage: use OpenMock as a context manager to mock OpenSearch client calls."},"warnings":[{"fix":"Upgrade Python to >=3.10 and use 'from openmock import OpenMock'.","message":"Version 3.x dropped support for Python <3.10 and changed the import from 'openmock' (previously 'openmock.OpenMock' was sometimes imported incorrectly). Ensure your tests run on Python >=3.10.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Place all related OpenSearch operations within a single with block, or use the decorator form '@OpenMock()' for a whole test function.","message":"OpenMock does not persist state between different with-blocks or across separate test cases. Each context manager starts with a fresh mock cluster.","severity":"gotcha","affected_versions":"all"},{"fix":"Check the openmock documentation for the list of supported APIs. For unsupported operations, consider mocking manually or using a real test cluster.","message":"The mock only supports a subset of OpenSearch APIs. Advanced features like snapshot/restore, scroll, or compatibility with specific OpenSearch plugins may not be available.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.10':39 '3.2.0':36 'behavior':28 'cadenc':41 'cluster':33 'current':34 'elasticsearch':13 'in-memori':21 'irregular':42 'librari':9 'lightweight':20 'memori':23 'mock':3,11,24,45 'need':30 'openmock':1 'opensearch':2,12,27,43 'opensearchpi':46 'oper':14 'provid':18 'python':5,8,38,47 'real':32 'releas':40 'requir':37 'simul':26 'test':6,17,44 'unit':16 'version':35 'without':29","created_at":"2026-05-01T06:02:36.180921+00:00","updated_at":"2026-05-01T06:02:36.180921+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.2.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/matthewdeanmartin/openmock","docs":"https://openmock.readthedocs.io/en/latest/","changelog":null,"pypi":"https://pypi.org/project/openmock/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}