50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
|
|
import lxml.html
|
||
|
|
|
||
|
|
from django.test import TestCase
|
||
|
|
|
||
|
|
from apps.lyric.models import Token, User, Wallet
|
||
|
|
|
||
|
|
|
||
|
|
class WalletViewTest(TestCase):
|
||
|
|
def setUp(self):
|
||
|
|
self.user = User.objects.create(email="capman@test.io")
|
||
|
|
self.client.force_login(self.user)
|
||
|
|
response = self.client.get("/dashboard/wallet/")
|
||
|
|
self.parsed = lxml.html.fromstring(response.content)
|
||
|
|
|
||
|
|
def test_wallet_page_requires_login(self):
|
||
|
|
self.client.logout()
|
||
|
|
response = self.client.get("/dashboard/wallet/")
|
||
|
|
self.assertRedirects(
|
||
|
|
response, "/?next=/dashboard/wallet/", fetch_redirect_response=False
|
||
|
|
)
|
||
|
|
|
||
|
|
def test_wallet_page_renders(self):
|
||
|
|
[el] = self.parsed.cssselect("#id_writs_balance")
|
||
|
|
self.assertEqual(el.text_content().strip(), "144")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_esteem_balance(self):
|
||
|
|
[el] = self.parsed.cssselect("#id_esteem_balance")
|
||
|
|
self.assertEqual(el.text_content().strip(), "0")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_coin_on_a_string(self):
|
||
|
|
[_] = self.parsed.cssselect("#id_coin_on_a_string")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_free_token(self):
|
||
|
|
[_] = self.parsed.cssselect("#id_free_token_0")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_payment_methods_section(self):
|
||
|
|
[_] = self.parsed.cssselect("#id_add_payment_method")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_stripe_payment_element(self):
|
||
|
|
[_] = self.parsed.cssselect("#id_stripe_payment_element")
|
||
|
|
|
||
|
|
def test_wallet_page_shows_tithe_token_shop(self):
|
||
|
|
[_] = self.parsed.cssselect("#id_tithe_token_shop")
|
||
|
|
|
||
|
|
def test_tithe_token_shop_shows_bundle(self):
|
||
|
|
bundles = self.parsed.cssselect("#id_tithe_token_shop .token-bundle")
|
||
|
|
self.assertGreater(len(bundles), 0)
|
||
|
|
|
||
|
|
|