{"id":18754647,"url":"https://github.com/reloadware/stickybeak","last_synced_at":"2025-04-13T00:32:18.875Z","repository":{"id":48885635,"uuid":"382414607","full_name":"reloadware/stickybeak","owner":"reloadware","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-03T10:38:00.000Z","size":1847,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T19:03:56.078Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reloadware.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-02T17:14:31.000Z","updated_at":"2024-09-03T10:38:03.000Z","dependencies_parsed_at":"2024-11-07T17:49:34.766Z","dependency_job_id":null,"html_url":"https://github.com/reloadware/stickybeak","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":0.05970149253731338,"last_synced_commit":"7d8457171a266a87eb92a96e6a6949faca315ff0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reloadware%2Fstickybeak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reloadware%2Fstickybeak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reloadware%2Fstickybeak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reloadware%2Fstickybeak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reloadware","download_url":"https://codeload.github.com/reloadware/stickybeak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027400,"owners_count":21035594,"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":[],"created_at":"2024-11-07T17:29:37.114Z","updated_at":"2025-04-13T00:32:16.982Z","avatar_url":"https://github.com/reloadware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n=============================================\nStickybeak - Life changing E2E tests solution\n=============================================\n\n.. image:: https://badge.fury.io/py/stickybeak.svg\n    :target: https://pypi.org/project/stickybeak/\n\n.. image:: https://github.com/reloadware/stickybeak/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/reloadware/stickybeak/actions/workflows/test.yml/badge.svg\n\n.. image:: https://img.shields.io/badge/python-3.6-blue.svg\n    :target: https://www.python.org/downloads/release/python-360/\n\n.. image:: https://img.shields.io/badge/python-3.7-blue.svg\n    :target: https://www.python.org/downloads/release/python-370/\n\n.. image:: https://img.shields.io/badge/python-3.8-blue.svg\n    :target: https://www.python.org/downloads/release/python-380/\n\n.. image:: https://img.shields.io/badge/python-3.9-blue.svg\n    :target: https://www.python.org/downloads/release/python-390/\n\n\nStickybeak is an end to end test helper library that saves lots of testing endpoints and boilerplate code.\nUsually end to end testing is hard to debug when something goes wrong since modern microservice architecture can be\nquite convoluted. This library can flatten structure of even the most complex application and help developers write\ntests that are easy to debug and reflect real life scenarios.\n\nThis can save Hundreds of unit and integration tests.\n\nHow does it work\n----------------\nStickybeak uses code injection to execute arbitrary python code on remote servers in a local environment or dedicated\ncentralized testing microservice.\nCode injection might sound scary but this solution is completely safe since code injection endpoints are only enabled\nin testing or staging environment.\nResults of executed code including all local variables or raised exceptions are pickled on remote server and sent back\nto the testing script where are unpickled and available for further testing and debugging - just like the code was\nexecuted locally.\n\nPretty amazing huh :) ?\n\n\nAt the moment stickybeak supports Django and Flask frameworks.\n\n\nInstallation\n------------\n.. code-block:: console\n\n    pip install stickybeak\n\n\nExample usage\n-------------\n\nDjango app (remote server)\n##########################\n\nTo enable stickybeak in a django application add the following line to your :code:`urls.py` file:\n\n.. code-block:: python\n\n    path(\"stickybeak/\", include(\"stickybeak.dj.urls\")),\n\n\nAnd add :code:`stickybeak` to :code:`INSTALLED_APPS` list.\n\nFlask app (remote server)\n#########################\nTo enable stickybeak in a flask application add :code:`setup(app)` as follows:\n\n.. code-block:: python\n\n    from flask import Flask\n    from stickybeak.flask_view import setup\n\n    app = Flask(__name__)\n    setup(app)\n\n\nTesting app (local server)\n##########################\n\nFunctions\n+++++++++\nFunction arguments and returns as well as default arguments are allowed.\n\n.. code-block:: python\n\n    from stickybeak.injector import DjangoInjector\n\n    injector = DjangoInjector(address='http://django-srv:8000',\n                              django_settings_module='django_srv.settings')\n\n    @injector.function\n    def fun(a: int, b: int = 2) -\u003e float:\n        return a / b\n\n    fun(2)\n\n\nExceptions\n++++++++++\nException are forwarded from remote to local server so the following piece of code raises :code:`ZeroDivisionError`:\n\n.. code-block:: python\n\n    from stickybeak.injector import DjangoInjector\n\n    injector = DjangoInjector(address='http://django-srv:8000',\n                              django_settings_module='django_srv.settings')\n\n    @injector.function\n    def fun() -\u003e float:\n        a = 1\n        b = 0\n        return a / b\n\n    fun()  # raises ZeroDivisionError\n\n\n\nUsing complex objects from a remote server locally\n++++++++++++++++++++++++++++++++++++++++++++++++++\nObjects are pickled on the remote side and send back to the local script and are available for further inspection or use.\n\n.. code-block:: python\n\n    @self.injector.function\n    def fun():\n        from app.models import Currency\n\n        currency = Currency()\n        currency.name = \"test_currency\"\n        currency.endpoint = \"test_endpoint\"\n        currency.save()\n        return Currency.objects.all()[0]  # noqa\n\n    ret: object = fun()\n    assert ret.name == \"test_currency\"\n    assert ret.endpoint == \"test_endpoint\"\n\nClasses\n+++++++\nThe same concepts go to classes. Only classmethods are allowed at the moment.\n\n.. code-block:: python\n\n    @injector.klass\n    class Interface:\n        @classmethod\n        def fun(cls, x: int) -\u003e int:\n            a = 1\n            b = 2\n            return a + b + x\n\n        @classmethod\n        def fun2(cls, x: int) -\u003e int:\n            c = 3\n            d = 4\n            return c + d + x\n\n        @classmethod\n        def fun3(cls) -\u003e int:\n            return cls.fun(5) + cls.fun2(x=5)\n\n    Interface.fun(1)  # 4\n    Interface.fun2(2)  # 9\n    Interface.fun3() # 20\n\nDevelopment\n-----------\nStickybeak uses pipenv. To install packages run:\n\n.. code-block:: console\n\n    pipenv install\n\n\nStarting test servers\n#####################\n.. code-block:: console\n\n    honcho start\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freloadware%2Fstickybeak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freloadware%2Fstickybeak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freloadware%2Fstickybeak/lists"}