bounty board feature buyers to see bounty boards seller profile page (like have theme chooser) Have the game and set name be filters. Add cards to vault manually update card inventory add to have the autocomplete for the card - store analytics, clicks, views, link to store (url/QR code) bulk item inventory creation -- Make the banner feature flag driven so I can have a beta site setup like the primary site don't use primary key values in urls - update to use uuid4 values site analytics. tianji is being sent item potent on the mtg and lorcana populate scripts Card item images for specific listings check that when you buy a card it is in the vault Buys should be able to search on store inventories More pie charts for the seller! post bounty board is slow to load seller reviews/ratings - show a historgram - need a way for someone to rate Report a seller feature for buyer to report Make sure the stlying is consistent based on the theme choosen smart minimum order quantity and shipping amounts (defined by the store itself) put virtual packs behind a feature flag like bounty board proxy service feature flag Terms of Service new description for TCGKof store SSN, ITIN, and EIN optomize for SEO
88 lines
3.3 KiB
Python
88 lines
3.3 KiB
Python
from django.test import TestCase, Client
|
|
from django.urls import reverse
|
|
from django.contrib.auth import get_user_model
|
|
from .models import Seller, Game, Set, Card, Bounty
|
|
from django.conf import settings
|
|
|
|
User = get_user_model()
|
|
|
|
class BountyCreateTest(TestCase):
|
|
def setUp(self):
|
|
# Ensure feature is on (might need to mock settings if not settable directly,
|
|
# but usually tests run with default settings. We need ensuring it's True)
|
|
# Note: In some setups, modifying settings in test needs override_settings
|
|
|
|
self.user = User.objects.create_user(username='bounty_seller', password='password')
|
|
self.seller = Seller.objects.create(
|
|
user=self.user,
|
|
store_name='Bounty Store',
|
|
slug='bounty-store'
|
|
)
|
|
|
|
self.game = Game.objects.create(name='Bounty Game', slug='bounty-game')
|
|
self.set = Set.objects.create(game=self.game, name='Bounty Set')
|
|
self.card = Card.objects.create(set=self.set, name='Bounty Card')
|
|
|
|
self.client = Client()
|
|
self.client.force_login(self.user)
|
|
self.url = reverse('store:bounty_create')
|
|
|
|
def test_create_bounty_with_card_id(self):
|
|
# Simulate selecting a card via autocomplete
|
|
data = {
|
|
'card_name': 'Bounty Card',
|
|
'card_id': self.card.id,
|
|
'target_price': '100.00',
|
|
'quantity_wanted': 1,
|
|
# Title is optional if card picked? Form logic says "if no card and no title raise error"
|
|
# Our view logic: if card_id -> get card -> set bounty.card.
|
|
# Form clean: if not card_id and not title and not card_name -> Error.
|
|
}
|
|
|
|
with self.settings(FEATURE_BOUNTY_BOARD=True):
|
|
response = self.client.post(self.url, data)
|
|
|
|
self.assertRedirects(response, reverse('store:bounty_list'))
|
|
|
|
# Verify
|
|
bounty = Bounty.objects.first()
|
|
self.assertIsNotNone(bounty)
|
|
self.assertEqual(bounty.card, self.card)
|
|
self.assertEqual(bounty.seller, self.seller)
|
|
# Title should be auto-set in save() if empty
|
|
self.assertEqual(bounty.title, "Buying Bounty Card")
|
|
|
|
def test_create_bounty_with_name_fallback(self):
|
|
# Simulate typing a name but not selecting a card (no ID)
|
|
data = {
|
|
'card_name': 'Generic Card',
|
|
'card_id': '',
|
|
'target_price': '50.00',
|
|
'quantity_wanted': 1
|
|
}
|
|
|
|
with self.settings(FEATURE_BOUNTY_BOARD=True):
|
|
response = self.client.post(self.url, data)
|
|
|
|
self.assertRedirects(response, reverse('store:bounty_list'))
|
|
|
|
bounty = Bounty.objects.last()
|
|
self.assertIsNone(bounty.card)
|
|
self.assertEqual(bounty.title, 'Generic Card')
|
|
|
|
def test_create_bounty_validation_error(self):
|
|
# Empty everything
|
|
data = {
|
|
'card_name': '',
|
|
'card_id': '',
|
|
'target_price': '50.00',
|
|
'quantity_wanted': 1
|
|
}
|
|
|
|
with self.settings(FEATURE_BOUNTY_BOARD=True):
|
|
response = self.client.post(self.url, data)
|
|
|
|
self.assertEqual(response.status_code, 200) # Form errors, no redirect
|
|
form = response.context['form']
|
|
self.assertIn("You must either select a Card or provide a Title.", form.non_field_errors())
|