Skip to content

Instantly share code, notes, and snippets.

View thekie's full-sized avatar

Kie Codes thekie

View GitHub Profile
@thekie
thekie / CeleryTestCase.py
Last active December 3, 2020 10:26
Celery only gives instructions on how to write integration tests using pyTest not the god ol' python UnitTest framework. So I wrote a CeleryTestCase which can be used as a base class for your integration tests using a real celery worker in the background.
from unittest import TestCase
from celery.contrib.testing import worker
class CeleryTestCase(TestCase):
@property
def celery_app(self):
"""
Override this method to provide this testcase with the celery app under test
"""
import copy
import json
import os
from openai import OpenAI
client = OpenAI(
api_key="<Your api key here>"
)