PW-680 fixed a bug where exchange_rate and price_adjustments didnt reload properly between requests
This commit is contained in:
+48
-40
@@ -1,6 +1,7 @@
|
||||
# coding=UTF-8
|
||||
|
||||
import unittest2
|
||||
import mock
|
||||
from api.lib.prices import *
|
||||
from tests.factories import DesignerFactory, ContractCustomerFactory, InquiryFactory
|
||||
from api.models import market
|
||||
@@ -169,70 +170,77 @@ class TestPrice(unittest2.TestCase):
|
||||
self.assertEqual(111, old_canvas_price(width=100, height=100, material=standard_canvas, market=russia, framed=False,
|
||||
designer=designer_moomin, reseller=piterra))
|
||||
|
||||
|
||||
def test_wallpaper_custom_inquiry_price(self):
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="NL", pricepremium=0,
|
||||
with mock.patch.object(Inquiry, 'market', nl):
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="NL", pricepremium=0,
|
||||
width=350, height=270, price_effect=0, price_retouch=160.00, material=standard_wallpaper)
|
||||
|
||||
self.assertEqual(333, inquiry_price(inquiry))
|
||||
self.assertEqual(310, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(160, inquiry.price_retouch)
|
||||
self.assertEqual(18.4, inquiry.local_price_retouch(rounded=False))
|
||||
self.assertEqual(22, inquiry.local_price_retouch(
|
||||
rounded=True, inc_vat=True))
|
||||
self.assertEqual(333, inquiry_price(inquiry))
|
||||
self.assertEqual(310, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(160, inquiry.price_retouch)
|
||||
self.assertEqual(18.4, inquiry.local_price_retouch(rounded=False))
|
||||
self.assertEqual(22, inquiry.local_price_retouch(
|
||||
rounded=True, inc_vat=True))
|
||||
|
||||
# test with different material
|
||||
self.assertEqual(342, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, material=premium_wallpaper))
|
||||
self.assertEqual(364, inquiry_price(
|
||||
inquiry, material=premium_wallpaper))
|
||||
# test with different material
|
||||
self.assertEqual(342, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, material=premium_wallpaper))
|
||||
self.assertEqual(364, inquiry_price(
|
||||
inquiry, material=premium_wallpaper))
|
||||
|
||||
def test_wallpaper_product_inquiry_price(self):
|
||||
designer = DesignerFactory()
|
||||
designer.pricepremium = 4
|
||||
product = Product(designer=designer)
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="SE", pricepremium=0,
|
||||
with mock.patch.object(Inquiry, 'market', sweden):
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="SE", pricepremium=0,
|
||||
width=350, height=280, price_retouch=0, material=standard_wallpaper, product=product)
|
||||
|
||||
self.assertEqual(3007, inquiry_price(inquiry))
|
||||
self.assertEqual(3007, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(3312, inquiry_price(
|
||||
inquiry, material=premium_wallpaper))
|
||||
self.assertEqual(3007, inquiry_price(inquiry))
|
||||
self.assertEqual(3007, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(3312, inquiry_price(
|
||||
inquiry, material=premium_wallpaper))
|
||||
|
||||
def test_wallpaper_product2_inquiry_price(self):
|
||||
designer = DesignerFactory()
|
||||
designer.pricepremium = 4
|
||||
product = Product(designer=designer)
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="SE", pricepremium=25,
|
||||
width=250, height=400, price_retouch=200, material=standard_wallpaper, product=product)
|
||||
with mock.patch.object(Inquiry, 'market', sweden):
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="SE", pricepremium=25,
|
||||
width=250, height=400, price_retouch=200, material=standard_wallpaper, product=product)
|
||||
|
||||
self.assertEqual(3835, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(200, inquiry.price_retouch)
|
||||
self.assertEqual(250, inquiry.local_price_retouch(
|
||||
rounded=True, inc_vat=True))
|
||||
self.assertEqual(3835, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(200, inquiry.price_retouch)
|
||||
self.assertEqual(250, inquiry.local_price_retouch(
|
||||
rounded=True, inc_vat=True))
|
||||
|
||||
def test_wallpaper_piterra_inquiry_price(self):
|
||||
product = Product(designer=None)
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="RU", width=150, height=211, dealer_store=piterra, pricepremium=36.029411,
|
||||
material=standard_wallpaper, product=product)
|
||||
with mock.patch.object(Inquiry, 'market', russia):
|
||||
inquiry = Inquiry(product_group="photo-wallpaper", territory="RU", width=150, height=211, dealer_store=piterra, pricepremium=36.029411,
|
||||
material=standard_wallpaper, product=product)
|
||||
|
||||
self.assertEqual(138, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(152, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, material=premium_wallpaper))
|
||||
self.assertEqual(138, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(152, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, material=premium_wallpaper))
|
||||
|
||||
def test_canvas_custom_inquiry_price(self):
|
||||
inquiry = Inquiry(product_group='canvas', territory='SE', width=100, height=100,
|
||||
framed=True, price_retouch=200, pricepremium=0, material=standard_canvas)
|
||||
with mock.patch.object(Inquiry, 'market', sweden):
|
||||
inquiry = Inquiry(product_group='canvas', territory='SE', width=100, height=100,
|
||||
framed=True, price_retouch=200, pricepremium=0, material=standard_canvas)
|
||||
|
||||
self.assertEqual(1520, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(1770, inquiry_price(inquiry, inc_price_retouch=True))
|
||||
self.assertEqual(999, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, framed=False))
|
||||
self.assertEqual(1520, inquiry_price(inquiry, inc_price_retouch=False))
|
||||
self.assertEqual(1770, inquiry_price(inquiry, inc_price_retouch=True))
|
||||
self.assertEqual(999, inquiry_price(
|
||||
inquiry, inc_price_retouch=False, framed=False))
|
||||
|
||||
def test_canvas_piterra_inquiry_price(self):
|
||||
inquiry = Inquiry(product_group='canvas', territory='RU', width=100, height=100,
|
||||
framed=True, dealer_store=piterra, pricepremium=0, material=standard_canvas)
|
||||
with mock.patch.object(Inquiry, 'market', russia):
|
||||
inquiry = Inquiry(product_group='canvas', territory='RU', width=100, height=100,
|
||||
framed=True, dealer_store=piterra, pricepremium=0, material=standard_canvas)
|
||||
|
||||
# note: site currently calculates this as €150 which is wrong because
|
||||
# it does not add dealer_store.pricepremium to the frame price
|
||||
self.assertEqual(165, inquiry_price(inquiry))
|
||||
self.assertEqual(109, inquiry_price(inquiry, framed=False))
|
||||
# note: site currently calculates this as €150 which is wrong because
|
||||
# it does not add dealer_store.pricepremium to the frame price
|
||||
self.assertEqual(165, inquiry_price(inquiry))
|
||||
self.assertEqual(109, inquiry_price(inquiry, framed=False))
|
||||
|
||||
Reference in New Issue
Block a user