added missing dunderinits to apps.applets.tests & .tests.integrated; some of the test_models ITs never were passing til now but never tested either; new apps.lyric.tests.integrated.test_models cover missing Applet model return
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,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
||||||
0
src/apps/applets/tests/__init__.py
Normal file
0
src/apps/applets/tests/__init__.py
Normal file
0
src/apps/applets/tests/integrated/__init__.py
Normal file
0
src/apps/applets/tests/integrated/__init__.py
Normal file
@@ -44,8 +44,8 @@ class UserAppletModelTest(TestCase):
|
|||||||
class AppletContextTest(TestCase):
|
class AppletContextTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user = User.objects.create(email="a@b.cde")
|
self.user = User.objects.create(email="a@b.cde")
|
||||||
self.dash_applet = Applet.objects.create(slug="username", name="Username", context="dashboard")
|
self.dash_applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username", "context": "dashboard"})
|
||||||
self.game_applet = Applet.objects.create(slug="new-game", name="New Game", context="gameboard")
|
self.game_applet, _ = Applet.objects.get_or_create(slug="new-game", defaults={"name": "New Game", "context": "gameboard"})
|
||||||
|
|
||||||
def test_filters_by_context(self):
|
def test_filters_by_context(self):
|
||||||
result = applet_context(self.user, "dashboard")
|
result = applet_context(self.user, "dashboard")
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
@@ -3,7 +3,7 @@ from django.contrib import auth
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from apps.lyric.models import LoginToken, Token, User, Wallet
|
from apps.lyric.models import LoginToken, PaymentMethod, Token, User, Wallet
|
||||||
|
|
||||||
|
|
||||||
class UserModelTest(TestCase):
|
class UserModelTest(TestCase):
|
||||||
@@ -96,3 +96,58 @@ class TokenCreationTest(TestCase):
|
|||||||
delta = free.expires_at - timezone.now()
|
delta = free.expires_at - timezone.now()
|
||||||
self.assertLessEqual(delta.days, 7)
|
self.assertLessEqual(delta.days, 7)
|
||||||
self.assertGreater(delta.total_seconds(), 0)
|
self.assertGreater(delta.total_seconds(), 0)
|
||||||
|
|
||||||
|
|
||||||
|
class WalletTooltipTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create(email="wallet@test.io")
|
||||||
|
self.wallet = Wallet.objects.get(user=self.user)
|
||||||
|
|
||||||
|
def test_tooltip_name(self):
|
||||||
|
self.assertEqual(self.wallet.tooltip_name(), "Wallet")
|
||||||
|
|
||||||
|
def test_tooltip_description(self):
|
||||||
|
self.wallet.writs = 144
|
||||||
|
self.wallet.esteem = 12
|
||||||
|
self.assertEqual(self.wallet.tooltip_description(), "144 writs · 12 esteem")
|
||||||
|
|
||||||
|
def test_tooltip_shoptalk_returns_none(self):
|
||||||
|
self.assertIsNone(self.wallet.tooltip_shoptalk())
|
||||||
|
|
||||||
|
def test_tooltip_expiry_returns_none(self):
|
||||||
|
self.assertIsNone(self.wallet.tooltip_expiry())
|
||||||
|
|
||||||
|
def test_tooltip_text(self):
|
||||||
|
self.assertEqual(self.wallet.tooltip_text(), "Wallet: 144 writs · 0 esteem")
|
||||||
|
|
||||||
|
|
||||||
|
class TokenTooltipTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create(email="tokens@test.io")
|
||||||
|
|
||||||
|
def test_tithe_tooltip_description(self):
|
||||||
|
tithe = Token.objects.create(user=self.user, token_type=Token.TITHE)
|
||||||
|
self.assertEqual(tithe.tooltip_description(), "+ Writ bonus")
|
||||||
|
|
||||||
|
def test_tooltip_description_empty_fallback(self):
|
||||||
|
# token_type other than COIN/FREE/TITHE hits the bare return ""
|
||||||
|
token = Token(user=self.user, token_type="")
|
||||||
|
self.assertEqual(token.tooltip_description(), "")
|
||||||
|
|
||||||
|
def test_tooltip_expiry_empty_when_no_expiry_and_not_coin(self):
|
||||||
|
free = Token.objects.get(user=self.user, token_type=Token.FREE)
|
||||||
|
free.expires_at = None
|
||||||
|
self.assertEqual(free.tooltip_expiry(), "")
|
||||||
|
|
||||||
|
def test_tooltip_shoptalk_none_for_non_coin(self):
|
||||||
|
free = Token.objects.get(user=self.user, token_type=Token.FREE)
|
||||||
|
self.assertIsNone(free.tooltip_shoptalk())
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentMethodTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create(email="pay@test.io")
|
||||||
|
|
||||||
|
def test_str(self):
|
||||||
|
pm = PaymentMethod(user=self.user, stripe_pm_id="pm_123", last4="4242", brand="Visa")
|
||||||
|
self.assertEqual(str(pm), "Visa ....4242")
|
||||||
|
|||||||
Reference in New Issue
Block a user