Setup test script for testing the app

This commit is contained in:
2025-10-02 20:58:20 -04:00
parent c0995c90e1
commit e1a83ab876
2 changed files with 50 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
from django.test import TestCase from django.test import TestCase
from ai_blocker.ualist_backers import ConfigBackedUAList from .ualist_backers import ConfigBackedUAList
from middleware import load_backing_class from .middleware import load_backing_class
# Create your tests here. # Create your tests here.
class BackerConfigTestCase(TestCase): class BackerConfigTestCase(TestCase):

48
test_app.py Normal file
View File

@@ -0,0 +1,48 @@
import sys
try:
import django
from django.conf import settings
settings.configure(
DEBUG=True,
USE_TZ=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
# ROOT_URLCONF="test_app.urls",
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"ai_blocker",
],
SITE_ID=1,
NOSE_ARGS=['-s'],
FIXTURE_DIRS=['ai_blocker/fixtures']
)
django.setup()
from django.test.utils import get_runner
except ImportError:
raise ImportError("To fix this error, run: pipenv install")
def run_tests(*test_args):
if not test_args:
test_args = ['ai_blocker.tests']
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(test_args)
if failures:
sys.exit(failures)
if __name__ == '__main__':
run_tests(*sys.argv[1:])