Skip to main content

Stickybeak - Life changing E2E tests solution

https://badge.fury.io/py/stickybeak.svg https://github.com/reloadware/stickybeak/actions/workflows/test.yml/badge.svg https://img.shields.io/badge/python-3.6-blue.svg https://img.shields.io/badge/python-3.7-blue.svg https://img.shields.io/badge/python-3.8-blue.svg https://img.shields.io/badge/python-3.9-blue.svg

Stickybeak is an end to end test helper library that saves lots of testing endpoints and boilerplate code. Usually end to end testing is hard to debug when something goes wrong since modern microservice architecture can be quite convoluted. This library can flatten structure of even the most complex application and help developers write tests that are easy to debug and reflect real life scenarios.

This can save Hundreds of unit and integration tests.

How does it work

Stickybeak uses code injection to execute arbitrary python code on remote servers in a local environment or dedicated centralized testing microservice. Code injection might sound scary but this solution is completely safe since code injection endpoints are only enabled in testing or staging environment. Results of executed code including all local variables or raised exceptions are pickled on remote server and sent back to the testing script where are unpickled and available for further testing and debugging - just like the code was executed locally.

Pretty amazing huh :) ?

At the moment stickybeak supports Django and Flask frameworks.

Installation

pip install stickybeak

Example usage

Django app (remote server)

To enable stickybeak in a django application add the following line to your urls.py file:

path("stickybeak/", include("stickybeak.dj.urls")),

And add stickybeak to INSTALLED_APPS list.

Flask app (remote server)

To enable stickybeak in a flask application add setup(app) as follows:

from flask import Flask
from stickybeak.flask_view import setup

app = Flask(__name__)
setup(app)

Testing app (local server)

Functions

Function arguments and returns as well as default arguments are allowed.

from stickybeak.injector import DjangoInjector

injector = DjangoInjector(address='http://django-srv:8000',
                          django_settings_module='django_srv.settings')

@injector.function
def fun(a: int, b: int = 2) -> float:
    return a / b

fun(2)

Exceptions

Exception are forwarded from remote to local server so the following piece of code raises ZeroDivisionError:

from stickybeak.injector import DjangoInjector

injector = DjangoInjector(address='http://django-srv:8000',
                          django_settings_module='django_srv.settings')

@injector.function
def fun() -> float:
    a = 1
    b = 0
    return a / b

fun()  # raises ZeroDivisionError

Using complex objects from a remote server locally

Objects are pickled on the remote side and send back to the local script and are available for further inspection or use.

@self.injector.function
def fun():
    from app.models import Currency

    currency = Currency()
    currency.name = "test_currency"
    currency.endpoint = "test_endpoint"
    currency.save()
    return Currency.objects.all()[0]  # noqa

ret: object = fun()
assert ret.name == "test_currency"
assert ret.endpoint == "test_endpoint"

Classes

The same concepts go to classes. Only classmethods are allowed at the moment.

@injector.klass
class Interface:
    @classmethod
    def fun(cls, x: int) -> int:
        a = 1
        b = 2
        return a + b + x

    @classmethod
    def fun2(cls, x: int) -> int:
        c = 3
        d = 4
        return c + d + x

    @classmethod
    def fun3(cls) -> int:
        return cls.fun(5) + cls.fun2(x=5)

Interface.fun(1)  # 4
Interface.fun2(2)  # 9
Interface.fun3() # 20

Development

Stickybeak uses pipenv. To install packages run:

pipenv install

Starting test servers

honcho start

Release files for stickybeak 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stickybeak 0.9.6
File Size Uploaded
stickybeak-0.9.6.tar.gz 41.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stickybeak 0.9.6
File Interpreter ABI Platform
stickybeak-0.9.6-py3-none-any.whl Python 3 none any Details

Total release size: 89.5 kB

Release files / stickybeak-0.9.6.tar.gz

Download URL stickybeak-0.9.6.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cd8c575ddbf1ac07438ae5f1259c4a76f6c40ac9b7eb0ba408f045b9643770a6
BLAKE2b-256 checksum
How to use checksums
f4639334bca2928be5bc956be27014995479a947fb99a2e88be41d0deed3f6a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / stickybeak-0.9.6-py3-none-any.whl

Download URL stickybeak-0.9.6-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f070b008ec582e319e45ed8fdcdcefdc454260f08d1acac6400e0aef74f2ed0
BLAKE2b-256 checksum
How to use checksums
4372721052c86b2a2be08189c4ad5bc6576afd0e61216d0433cd2536696c0b89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page