from decimal import Decimal
from django.test import TestCase

from measurement.measures import Weight
from accounts.models import User
from core.models import (
    Product,
    ProductPhoto,
    Coupon,
    ShippingMethod,
    Order,
    Transaction,
    OrderLine,
    TrackingNumber,
)


class ProductModelTest(TestCase):
    fixtures = ['accounts.json']

    @classmethod
    def setUpTestData(cls):
        Product.objects.create(
            name='Pantomime',
            subtitle='Very Dark French Roast',
            description='Our darkest drip. A blend of five different beans roasted two ways. Organic Africa, Indonesia, and South and Central America.',
            sku='565656',
            price=Decimal('15.00'),
            weight=Weight(oz=16),
            visible_in_listings=True,
            sorting=1,
        )

    def test_get_absolute_url(self):
        product = Product.objects.get(pk=1)
        self.assertEqual(
            product.get_absolute_url(),
            '/dashboard/products/1/'
        )
