new core.runner helper to avoid local caching issues w. coverage tests; .settings, apps.dash.tests.ITs.test_wallet_views updated accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
import lxml.html
|
import lxml.html
|
||||||
|
|
||||||
from django.test import override_settings, TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from apps.applets.models import Applet, UserApplet
|
from apps.applets.models import Applet, UserApplet
|
||||||
from apps.lyric.models import Token, User, Wallet
|
from apps.lyric.models import Token, User, Wallet
|
||||||
|
|
||||||
|
|
||||||
@override_settings(COMPRESS_ENABLED=False)
|
|
||||||
class WalletViewTest(TestCase):
|
class WalletViewTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = User.objects.create(email="capman@test.io")
|
self.user = User.objects.create(email="capman@test.io")
|
||||||
@@ -49,7 +48,6 @@ class WalletViewTest(TestCase):
|
|||||||
self.assertGreater(len(bundles), 0)
|
self.assertGreater(len(bundles), 0)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(COMPRESS_ENABLED=False)
|
|
||||||
class WalletViewAppletContextTest(TestCase):
|
class WalletViewAppletContextTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = User.objects.create(email="walletctx@test.io")
|
self.user = User.objects.create(email="walletctx@test.io")
|
||||||
@@ -85,7 +83,6 @@ class WalletViewAppletContextTest(TestCase):
|
|||||||
[_] = parsed.cssselect(".gear-btn")
|
[_] = parsed.cssselect(".gear-btn")
|
||||||
|
|
||||||
|
|
||||||
@override_settings(COMPRESS_ENABLED=False)
|
|
||||||
class ToggleWalletAppletsTest(TestCase):
|
class ToggleWalletAppletsTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = User.objects.create(email="wallettoggle@test.io")
|
self.user = User.objects.create(email="wallettoggle@test.io")
|
||||||
|
|||||||
15
src/core/runner.py
Normal file
15
src/core/runner.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import time
|
||||||
|
from django.test.runner import DiscoverRunner
|
||||||
|
|
||||||
|
|
||||||
|
class RobustCompressorTestRunner(DiscoverRunner):
|
||||||
|
def setup_test_environment(self, **kwargs):
|
||||||
|
super().setup_test_environment(**kwargs)
|
||||||
|
from compressor.storage import CompressorFileStorage
|
||||||
|
_orig_save = CompressorFileStorage.save
|
||||||
|
def _robust_save(self, name, content):
|
||||||
|
for _ in range(5):
|
||||||
|
try: return _orig_save(self, name, content)
|
||||||
|
except PermissionError: time.sleep(0.05)
|
||||||
|
raise
|
||||||
|
CompressorFileStorage.save = _robust_save
|
||||||
@@ -14,8 +14,6 @@ from pathlib import Path
|
|||||||
import dj_database_url
|
import dj_database_url
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
if 'test' in sys.argv:
|
|
||||||
COMPRESS_ENABLED = False
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -206,3 +204,11 @@ MAILGUN_DOMAIN = "howdy.earthmanrpg.com" # Your Mailgun domain
|
|||||||
# Stripe payment settings
|
# Stripe payment settings
|
||||||
STRIPE_PUBLISHABLE_KEY = os.environ.get("STRIPE_PUBLISHABLE_KEY", "")
|
STRIPE_PUBLISHABLE_KEY = os.environ.get("STRIPE_PUBLISHABLE_KEY", "")
|
||||||
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "")
|
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "")
|
||||||
|
|
||||||
|
if 'test' in sys.argv:
|
||||||
|
import shutil
|
||||||
|
_cache_dir = BASE_DIR / 'static' / 'CACHE'
|
||||||
|
if _cache_dir.exists():
|
||||||
|
shutil.rmtree(_cache_dir, ignore_errors=True)
|
||||||
|
COMPRESS_CACHE_BACKEND = 'default'
|
||||||
|
TEST_RUNNER = 'core.runner.RobustCompressorTestRunner'
|
||||||
|
|||||||
Reference in New Issue
Block a user