{"id":28376605,"url":"https://github.com/apiaryio/dredd-hooks-python","last_synced_at":"2025-07-31T18:31:44.137Z","repository":{"id":34433399,"uuid":"38366703","full_name":"apiaryio/dredd-hooks-python","owner":"apiaryio","description":"Python Hooks for Dredd API Testing Framework","archived":true,"fork":false,"pushed_at":"2021-04-29T19:45:10.000Z","size":77,"stargazers_count":19,"open_issues_count":3,"forks_count":7,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-30T00:07:20.911Z","etag":null,"topics":["dredd","dredd-hooks","python","sjs-team"],"latest_commit_sha":null,"homepage":"http://dredd.rtfd.org/en/latest/hooks-python/","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/apiaryio.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":"2015-07-01T11:08:39.000Z","updated_at":"2024-11-24T04:47:09.000Z","dependencies_parsed_at":"2022-08-17T20:50:33.080Z","dependency_job_id":null,"html_url":"https://github.com/apiaryio/dredd-hooks-python","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/apiaryio/dredd-hooks-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fdredd-hooks-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fdredd-hooks-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fdredd-hooks-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fdredd-hooks-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apiaryio","download_url":"https://codeload.github.com/apiaryio/dredd-hooks-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fdredd-hooks-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262084795,"owners_count":23256295,"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":["dredd","dredd-hooks","python","sjs-team"],"created_at":"2025-05-30T00:07:21.364Z","updated_at":"2025-06-26T14:31:43.057Z","avatar_url":"https://github.com/apiaryio.png","language":"Python","readme":"===================================================\nPython Hooks Bridge for Dredd API Testing Framework\n===================================================\n\n.. image:: https://travis-ci.org/apiaryio/dredd-hooks-python.svg?branch=master\n    :target: https://travis-ci.org/apiaryio/dredd-hooks-python\n\nAbout\n=====\n\nThis package contains a bridge between `Dredd API Testing Framework`_\nand Python environment to ease implementation of testing hooks\nprovided by Dredd_. Write Dredd_ hooks in Python to glue together `API\nBlueprint`_ with your Python project\n\n.. _Dredd API Testing Framework: http://dredd.readthedocs.org/en/latest/\n.. _Dredd: http://dredd.readthedocs.org/en/latest/\n.. _API Blueprint: https://apiblueprint.org/\n\n\n\nUsage example:\n\n.. code-block:: python\n\n    import dredd_hooks as hooks\n\n    @hooks.before_all\n    def foo(transactions):\n        for t in transactions:\n            t['request']['headers']['content-type'] = 'application/json'\n\nDownload\n========\n\nYou can see all the `available versions`__ at PyPI_.\n\n__ http://pypi.python.org/pypi/dredd_hooks\n\n\nFrom source (tar.gz or checkout)\n--------------------------------\n\nUnpack the archive, enter the ``dredd-hooks-python`` directory and run::\n\n    python setup.py install\n\n\nSetuptools/PyPI_\n----------------\n\nAlternatively it can be installed from PyPI_, either manually\ndownloading the files and installing as described above or using::\n\n    pip install dredd_hooks\n\n.. _PyPI: http://pypi.python.org/pypi\n\nUsage\n=====\n\n1. Create a hook file in ``hooks.py``:\n\n.. code-block:: python\n\n     import dredd_hooks as hooks\n\n     @hooks.before(\"Machines \u003e Machines collection \u003e Get Machines\")\n     def before_hook(transaction):\n         transaction['skip'] = \"true\"\n\n\n2. Run it with Dredd::\n\n     $ dredd apiary.apib localhost:3000 --language python --hookfiles ./hooks.py\n\nAPI\n===\n\nModule ``dredd_hooks`` defines following decorators ``before``, ``after``,\n``before_all``, ``after_all``, ``before_each``, ``after_each``,\n``before_validation``, ``before_each_validation``. ``before``,\n``before_validation`` and ``after`` hooks are identified by `transaction\nname\n\u003chttp://dredd.readthedocs.org/en/latest/hooks/#getting-transaction-names\u003e`_.\n\nYou can combine those decorators together. So one function can be used\nfor different hooks but be aware that some hooks have a list of all\ntransactions as an argument and not a single transaction.\n\n.. code-block:: python\n\n     import dredd_hooks as hooks\n\n     @hooks.after_all\n     @hooks.before_all\n     @hooks.before_each\n     @hooks.after_each\n     @hooks.before_validation('Machines \u003e Machines collection \u003e Get Machines')\n     @hooks.before(\"Machines \u003e Machines collection \u003e Get Machines\")\n     @hooks.after(\"Machines \u003e Machines collection \u003e Get Machines\")\n     def multi_hook_function(trans):\n        if isinstance(trans, list):\n            print('called with list of transactions')\n        else:\n            if trans['name'] == 'Machines \u003e Machines collection \u003e Get Machines':\n                trans['skip'] = 'true'\n\n\nUsage is very similar to `sync JS hooks API\n\u003chttp://dredd.readthedocs.org/en/latest/hooks/#sync-api\u003e`_\n\nContributing\n============\n1. Fork it\n2. Create your feature branch (``git checkout -b my-newfeature``)\n3. Commit your changes (``git commit -am 'Add some feature'``)\n4. Push (``git push origin my-new-feature``)\n5. Create a new Pull Request\n\nTesting\n=======\n\nDon't forget about tests, see ``test`` directory. The project uses\n``unittest`` package and ``tox``.\n\nFor integration test with Dredd_ interface the project uses ruby based\n`aruba \u003chttps://github.com/cucumber/aruba\u003e`_ so to get it running make\nsure you have Ruby installed and then do::\n\n  $ bundle install\n\nAfter the setup you can run the test easily with::\n\n  $ bundle exec cucumber\n\nMore details about the integration test can be found in the\n`dredd-hooks-template repo\n\u003chttps://github.com/apiaryio/dredd-hooks-template\u003e`_\n\n\n:copyright: Copyright (c) 2015 Apiary Czech Republic, s.r.o.\n:license: MIT, see LICENSE for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiaryio%2Fdredd-hooks-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapiaryio%2Fdredd-hooks-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiaryio%2Fdredd-hooks-python/lists"}