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
96 lines
3.8 KiB
Python
96 lines
3.8 KiB
Python
from django.test import TestCase, Client
|
|
from django.contrib.auth import get_user_model
|
|
from .models import Seller, Game, Set, Card, CardListing, Cart, CartItem, Order
|
|
|
|
User = get_user_model()
|
|
|
|
class SmartPricingTests(TestCase):
|
|
def setUp(self):
|
|
# Create Seller User
|
|
self.seller_user = User.objects.create_user(username='seller', password='password')
|
|
self.seller = Seller.objects.create(
|
|
user=self.seller_user,
|
|
store_name='Smart Store',
|
|
slug='smart-store',
|
|
minimum_order_amount=10.00,
|
|
shipping_cost=2.50
|
|
)
|
|
|
|
# Create Buyer User
|
|
self.buyer_user = User.objects.create_user(username='buyer', password='password')
|
|
from users.models import Buyer
|
|
self.buyer = Buyer.objects.create(user=self.buyer_user)
|
|
|
|
# Create Products
|
|
self.game = Game.objects.create(name='Test Game', slug='test-game')
|
|
self.set = Set.objects.create(game=self.game, name='Test Set')
|
|
self.card = Card.objects.create(set=self.set, name='Test Card')
|
|
|
|
self.listing_cheap = CardListing.objects.create(
|
|
card=self.card, seller=self.seller, price=5.00, quantity=10, condition='NM'
|
|
)
|
|
self.listing_expensive = CardListing.objects.create(
|
|
card=self.card, seller=self.seller, price=15.00, quantity=10, condition='NM'
|
|
)
|
|
|
|
self.client = Client()
|
|
self.client.force_login(self.buyer_user)
|
|
|
|
def test_cart_shipping_below_minimum(self):
|
|
from django.urls import reverse
|
|
# Add cheap item (5.00) < 10.00 minimum
|
|
url = reverse('store:add_to_cart', args=[self.listing_cheap.uuid])
|
|
self.client.post(url)
|
|
|
|
# Determine cart directly
|
|
cart, _ = Cart.objects.get_or_create(buyer=self.buyer)
|
|
|
|
response = self.client.get(reverse('store:cart'))
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
# Check context data
|
|
cart_data = response.context['cart_data']
|
|
self.assertEqual(len(cart_data), 1)
|
|
data = cart_data[0]
|
|
|
|
self.assertEqual(data['subtotal'], 5.00)
|
|
self.assertEqual(data['shipping_cost'], 2.50)
|
|
self.assertEqual(data['total'], 7.50)
|
|
self.assertEqual(data['free_shipping_needed'], 5.00)
|
|
|
|
# Check Final Calculation
|
|
self.assertEqual(response.context['grand_total'], 7.50)
|
|
|
|
def test_cart_shipping_above_minimum(self):
|
|
from django.urls import reverse
|
|
# Add expensive item (15.00) > 10.00 minimum
|
|
cart, _ = Cart.objects.get_or_create(buyer=self.buyer)
|
|
CartItem.objects.create(cart=cart, listing=self.listing_expensive, quantity=1)
|
|
|
|
response = self.client.get(reverse('store:cart'))
|
|
|
|
cart_data = response.context['cart_data']
|
|
data = cart_data[0]
|
|
|
|
self.assertEqual(data['subtotal'], 15.00)
|
|
self.assertEqual(data['shipping_cost'], 0)
|
|
self.assertEqual(data['total'], 15.00)
|
|
self.assertEqual(data['free_shipping_needed'], 0)
|
|
|
|
def test_checkout_shipping_application(self):
|
|
from django.urls import reverse
|
|
# Setup cart below minimum
|
|
cart, _ = Cart.objects.get_or_create(buyer=self.buyer)
|
|
CartItem.objects.create(cart=cart, listing=self.listing_cheap, quantity=1)
|
|
|
|
response = self.client.get(reverse('store:checkout'))
|
|
# Checkout redirects to my_packs (if virtual) or vault (users:vault)
|
|
# Since we have no virtual, it goes to vault.
|
|
# Check for 302 Found
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
# Verify Order
|
|
order = Order.objects.filter(buyer=self.buyer).first()
|
|
self.assertIsNotNone(order)
|
|
self.assertEqual(order.total_price, 7.50) # 5.00 + 2.50 shipping
|