Skip to content

Instantly share code, notes, and snippets.

@atuchak
atuchak / gist:334158570fd59da896da8e623f699a7f
Created December 13, 2023 15:34
CloudPayments Webhook Facade
from __future__ import annotations
from abc import abstractmethod, ABC
from typing import Callable
from django.conf import settings
from django.http import Http404
from rest_framework import status
from rest_framework.request import Request
from rest_framework.response import Response
import base64
import zlib
def b64_decode(s):
pad = b'=' * (-len(s) % 4)
return base64.urlsafe_b64decode(s + pad)
def decode_session_data(session_data: str):
@atuchak
atuchak / conftest.py
Last active September 2, 2022 11:56
pytest xdist django cache prefix per process
@pytest.fixture(autouse=True, scope='session')
def django_cache_add_xdist_key_prefix(request):
skip_if_no_django()
# prefix like gw0_, gw1_ etc on xdist processes
xdist_prefix = getattr(request.config, 'slaveinput', {}).get('slaveid')
if not xdist_prefix:
return