Esempio n. 1
0
 def testCreate(self):
     c = Carrier(key="test", active=True)
     c.save()
     t = ShippingTier(carrier=c, 
         min_total=Decimal("0.00"),
         price=Decimal("10.00"),
         )
     t.save()
     
     self.assertEqual(c.price(Decimal("0.00")), Decimal("10.00"))
Esempio n. 2
0
File: tests.py Progetto: 34/T
 def testCreate(self):
     c = Carrier(key="test", active=True)
     c.save()
     product = Product.objects.get(slug='dj-rocks')
     p = ProductShippingPrice(carrier=c, 
         product=product,
         price=Decimal("10.00"),
         )
     p.save()
     
     self.assertEqual(c.price(product), Decimal("10.00"))
Esempio n. 3
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (0, 10),
            (20, 15),
            (30, 16),
            (40, 17)
        )
        make_tiers(self.carrier, base_prices)
Esempio n. 4
0
File: tests.py Progetto: 34/T
 def test2Prices(self):
     c2 = Carrier(name="test2", active=True)
     c2.save()
     t = ProductShippingPrice(carrier=c2,
         product=self.product,
         price=Decimal("20.00"),
         )
     t.save()
     
     self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
     self.assertEqual(c2.price(self.product), Decimal("20.00"))
Esempio n. 5
0
    def testCreate(self):
        c = Carrier(key="test", active=True)
        c.save()
        t = ShippingTier(
            carrier=c,
            min_total=Decimal("0.00"),
            price=Decimal("10.00"),
        )
        t.save()

        self.assertEqual(c.price(Decimal("0.00")), Decimal("10.00"))
Esempio n. 6
0
 def testCreate(self):
     c = Carrier(key="test", active=True)
     c.save()
     t = QuantityTier(carrier=c, 
         quantity=Decimal('1'),
         handling=Decimal("10.00"),
         price=Decimal("0.00"),
         )
     t.save()
     
     self.assertEqual(c.price(1), Decimal("10.00"))
     self.assertEqual(c.price(4), Decimal("10.00"))
Esempio n. 7
0
    def test2Prices(self):
        c2 = Carrier(name="test2", active=True)
        c2.save()
        t = ProductShippingPrice(
            carrier=c2,
            product=self.product,
            price=Decimal("20.00"),
        )
        t.save()

        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
        self.assertEqual(c2.price(self.product), Decimal("20.00"))
Esempio n. 8
0
    def testCreate(self):
        c = Carrier(key="test", active=True)
        c.save()
        product = Product.objects.get(slug='dj-rocks')
        p = ProductShippingPrice(
            carrier=c,
            product=product,
            price=Decimal("10.00"),
        )
        p.save()

        self.assertEqual(c.price(product), Decimal("10.00"))
Esempio n. 9
0
    def testCreate(self):
        c = Carrier(key="test", active=True)
        c.save()
        t = QuantityTier(
            carrier=c,
            quantity=Decimal('1'),
            handling=Decimal("10.00"),
            price=Decimal("0.00"),
        )
        t.save()

        self.assertEqual(c.price(1), Decimal("10.00"))
        self.assertEqual(c.price(4), Decimal("10.00"))
Esempio n. 10
0
class TieredCarrierPricingTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        t = QuantityTier(carrier=self.carrier, 
            quantity=Decimal('1'),
            handling=Decimal("10.00"),
            price=Decimal("0.00"),
            )
        t.save()
        
    def testBase(self):
        self.assertEqual(self.carrier.price(1), Decimal("10.00"))
        self.assertEqual(self.carrier.price(10), Decimal("10.00"))
        self.assertEqual(self.carrier.price(100), Decimal("10.00"))
        
    def test2Prices(self):
        t = QuantityTier(carrier=self.carrier, 
            quantity=Decimal('10'),
            handling=Decimal("100.00"),
            price=Decimal("1.00"),
            )
        t.save()
        
        self.assertEqual(self.carrier.price(1), Decimal("10.00"))
        self.assertEqual(self.carrier.price(9), Decimal("10.00"))
        self.assertEqual(self.carrier.price(10), Decimal("110.00"))
        self.assertEqual(self.carrier.price(100), Decimal("200.00"))
Esempio n. 11
0
class TieredCarrierPricingTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        t = QuantityTier(
            carrier=self.carrier,
            quantity=Decimal('1'),
            handling=Decimal("10.00"),
            price=Decimal("0.00"),
        )
        t.save()

    def testBase(self):
        self.assertEqual(self.carrier.price(1), Decimal("10.00"))
        self.assertEqual(self.carrier.price(10), Decimal("10.00"))
        self.assertEqual(self.carrier.price(100), Decimal("10.00"))

    def test2Prices(self):
        t = QuantityTier(
            carrier=self.carrier,
            quantity=Decimal('10'),
            handling=Decimal("100.00"),
            price=Decimal("1.00"),
        )
        t.save()

        self.assertEqual(self.carrier.price(1), Decimal("10.00"))
        self.assertEqual(self.carrier.price(9), Decimal("10.00"))
        self.assertEqual(self.carrier.price(10), Decimal("110.00"))
        self.assertEqual(self.carrier.price(100), Decimal("200.00"))
Esempio n. 12
0
    def make_ship(self, ship_type):
        if ship_type == Constant.SHIP_TYPE_CARRIER:
            make_ship = Carrier()
        elif ship_type == Constant.SHIP_TYPE_BATTLE_SHIP:
            make_ship = Battleship()
        elif ship_type == Constant.SHIP_TYPE_CRUISER:
            make_ship = Cruiser()
        elif ship_type == Constant.SHIP_TYPE_DESTROYER:
            make_ship = Destroyer()
        elif ship_type == Constant.SHIP_TYPE_OIL_RIG:
            make_ship = Oilrig()
        else:
            make_ship = Carrier()

        return make_ship
Esempio n. 13
0
def get_user_carriers():
    '''Creates a tuple per user to create a selectfield with WTForms'''
    carriers = Carrier.get_carrier_by_user(user_id=session['user_id'])
    tup_carriers = []
    for carrier in carriers:
        tup_carriers.append((carrier.id, carrier.name))
    return tup_carriers
Esempio n. 14
0
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     t = ShippingTier(carrier=self.carrier, 
         min_total=Decimal("0.00"),
         price=Decimal("10.00"),
         )
     t.save()
Esempio n. 15
0
class TieredCarrierExpiringTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (1, 10, 0),
            (20, 20, 1),
            (30, 30, 2),
            (40, 40, 1)
        )
        make_tiers(self.carrier, base_prices)
        
    def testExpired(self):
        dt = datetime(2000, 1, 1)
        
        sale_prices = (
            (1, 1, 0),
            (20, 2, 1),
            (30, 3, 1),
            (40, 4, 1)
        )
        
        make_tiers(self.carrier, sale_prices, expires=dt)

        self.assertEqual(self.carrier.price(1), Decimal("10.00"))
        self.assertEqual(self.carrier.price(20), Decimal("40.00"))
        self.assertEqual(self.carrier.price(30), Decimal("90.00"))
        self.assertEqual(self.carrier.price(100), Decimal("140.00"))

    def testNotExpired(self):
        
        now = timezone.now()
        nextyear = datetime(now.year+1, now.month, now.day)
        sale_prices = (
            (1, 1, 0),
            (20, 2, 1),
            (30, 3, 1),
            (40, 4, 1)
        )
        
        make_tiers(self.carrier, sale_prices, expires=nextyear)

        self.assertEqual(self.carrier.price(1), Decimal("1.00"))
        self.assertEqual(self.carrier.price(10), Decimal("1.00"))
        self.assertEqual(self.carrier.price(20), Decimal("22.00"))
        self.assertEqual(self.carrier.price(30), Decimal("33.00"))
        self.assertEqual(self.carrier.price(100), Decimal("104.00"))
Esempio n. 16
0
File: tests.py Progetto: 34/T
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     self.product = Product.objects.get(slug='dj-rocks')
     t = ProductShippingPrice(carrier=self.carrier,
         product=self.product,
         price=Decimal("10.00"),
         )
     t.save()
Esempio n. 17
0
 def setUp(self):
     self.carrier = Carrier(name="pricing", active=True)
     self.carrier.save()
     t = QuantityTier(carrier=self.carrier, 
         quantity=Decimal('1'),
         handling=Decimal("10.00"),
         price=Decimal("0.00"),
         )
     t.save()
Esempio n. 18
0
class TieredCarrierExpiringTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (0, 10),
            (20, 15),
            (30, 16),
            (40, 17)
        )
        make_tiers(self.carrier, base_prices)
        
    def testExpired(self):
        dt = datetime(2000, 1, 1)
        
        sale_prices = (
            (0, 1),
            (20, 2),
            (30, 3),
            (40, 4)
        )
        
        make_tiers(self.carrier, sale_prices, expires=dt)

        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))
        self.assertEqual(self.carrier.price(Decimal("30.00")), Decimal("16.00"))
        self.assertEqual(self.carrier.price(Decimal("40.01")), Decimal("17.00"))

    def testNotExpired(self):
        
        now = datetime.now()
        nextyear = datetime(now.year+1, now.month, now.day)
        sale_prices = (
            (0, 1),
            (20, 2),
            (30, 3),
            (40, 4)
        )
        
        make_tiers(self.carrier, sale_prices, expires=nextyear)

        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("1.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("2.00"))
        self.assertEqual(self.carrier.price(Decimal("30.00")), Decimal("3.00"))
        self.assertEqual(self.carrier.price(Decimal("40.01")), Decimal("4.00"))

        
        
        
Esempio n. 19
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (0, 10),
            (20, 15),
            (30, 16),
            (40, 17)
        )
        make_tiers(self.carrier, base_prices)
Esempio n. 20
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = (
            (1, 10, 0),
            (20, 20, 1),
            (30, 30, 2),
            (40, 40, 1)
        )
        make_tiers(self.carrier, base_prices)
Esempio n. 21
0
class TieredCarrierPricingTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        t = ShippingTier(carrier=self.carrier, 
            min_total=Decimal("0.00"),
            price=Decimal("10.00"),
            )
        t.save()
        
    def testBase(self):
        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        
    def test2Prices(self):
        t = ShippingTier(carrier=self.carrier, 
            min_total=Decimal("20.00"),
            price=Decimal("15.00"),
            )
        t.save()
        
        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))

    def test4Prices(self):
        prices = (
            (20, 15),
            (30, 16),
            (40, 17)
        )
        
        make_tiers(self.carrier, prices)

        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))
        self.assertEqual(self.carrier.price(Decimal("25.00")), Decimal("15.00"))
        self.assertEqual(self.carrier.price(Decimal("30.00")), Decimal("16.00"))
        self.assertEqual(self.carrier.price(Decimal("39.99")), Decimal("16.00"))
        self.assertEqual(self.carrier.price(Decimal("40.01")), Decimal("17.00"))
Esempio n. 22
0
class TieredCarrierPricingTest(TestCase):
    fixtures = []

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        t = ShippingTier(carrier=self.carrier, 
            min_total=Decimal("0.00"),
            price=Decimal("10.00"),
            )
        t.save()
        
    def testBase(self):
        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        
    def test2Prices(self):
        t = ShippingTier(carrier=self.carrier, 
            min_total=Decimal("20.00"),
            price=Decimal("15.00"),
            )
        t.save()
        
        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))

    def test4Prices(self):
        prices = (
            (20, 15),
            (30, 16),
            (40, 17)
        )
        
        make_tiers(self.carrier, prices)

        self.assertEqual(self.carrier.price(Decimal("0.00")), Decimal("10.00"))
        self.assertEqual(self.carrier.price(Decimal("20.00")), Decimal("15.00"))
        self.assertEqual(self.carrier.price(Decimal("25.00")), Decimal("15.00"))
        self.assertEqual(self.carrier.price(Decimal("30.00")), Decimal("16.00"))
        self.assertEqual(self.carrier.price(Decimal("39.99")), Decimal("16.00"))
        self.assertEqual(self.carrier.price(Decimal("40.01")), Decimal("17.00"))
Esempio n. 23
0
def create(app):
    with app.app_context():
        db.create_all()
        print 'tables created'

        db.session.add(Carrier('at&t', 'txt.att.net'))
        db.session.add(Carrier('Verizon', 'vtext.com'))
        db.session.add(Carrier('T-Mobile', 'tmomail.net'))
        db.session.add(Carrier('Sprint', 'messaging.sprintpcs.com'))
        db.session.add(Carrier('US Cellular', 'email.uscc.net'))
        db.session.add(Carrier('Metro PCS', 'mymetropcs.com'))
        print 'default carriers added'
        db.session.commit()
Esempio n. 24
0
class ProductShippingPricingTest(TestCase):
    fixtures = ['products.yaml']

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        self.product = Product.objects.get(slug='dj-rocks')
        t = ProductShippingPrice(
            carrier=self.carrier,
            product=self.product,
            price=Decimal("10.00"),
        )
        t.save()

    def testBase(self):
        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))

    def test2Prices(self):
        c2 = Carrier(name="test2", active=True)
        c2.save()
        t = ProductShippingPrice(
            carrier=c2,
            product=self.product,
            price=Decimal("20.00"),
        )
        t.save()

        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
        self.assertEqual(c2.price(self.product), Decimal("20.00"))

    def testVariantPrices(self):
        """price for shipping a variant is the same as the master, except when it is explicitly set"""

        variant = Product.objects.get(slug='dj-rocks-s-b')

        self.assertEqual(self.carrier.price(variant), Decimal("10.00"))

        t = ProductShippingPrice(
            carrier=self.carrier,
            product=variant,
            price=Decimal("20.00"),
        )
        t.save()

        self.assertEqual(self.carrier.price(variant), Decimal("20.00"))
Esempio n. 25
0
File: tests.py Progetto: 34/T
class ProductShippingPricingTest(TestCase):
    fixtures = ['products.yaml']

    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()
        self.product = Product.objects.get(slug='dj-rocks')
        t = ProductShippingPrice(carrier=self.carrier,
            product=self.product,
            price=Decimal("10.00"),
            )
        t.save()
        
    def testBase(self):
        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
        
    def test2Prices(self):
        c2 = Carrier(name="test2", active=True)
        c2.save()
        t = ProductShippingPrice(carrier=c2,
            product=self.product,
            price=Decimal("20.00"),
            )
        t.save()
        
        self.assertEqual(self.carrier.price(self.product), Decimal("10.00"))
        self.assertEqual(c2.price(self.product), Decimal("20.00"))

    def testVariantPrices(self):
        """price for shipping a variant is the same as the master, except when it is explicitly set"""
        
        variant = Product.objects.get(slug='dj-rocks-s-b')
        
        self.assertEqual(self.carrier.price(variant), Decimal("10.00"))
        
        t = ProductShippingPrice(carrier=self.carrier,
            product=variant,
            price=Decimal("20.00"),
            )
        t.save()
        
        self.assertEqual(self.carrier.price(variant), Decimal("20.00"))
Esempio n. 26
0
    def _create_carrier(self, carrier_id: str, name: str) -> 'Carrier':
        """Создает экземпляр Carrier."""
        carrier = Carrier(carrier_id=carrier_id, name=name)
        self._carriers[carrier_id] = carrier

        return carrier
Esempio n. 27
0
    def setUp(self):
        self.carrier = Carrier(name="pricing", active=True)
        self.carrier.save()

        base_prices = ((1, 10, 0), (20, 20, 1), (30, 30, 2), (40, 40, 1))
        make_tiers(self.carrier, base_prices)