P5-6370 inquires should use markets instead of territores for calculating prices #36

This commit is contained in:
Martin Carlsson
2021-01-19 14:32:06 +01:00
committed by GitHub
parent 2692737100
commit dee7344ba5
6 changed files with 25 additions and 39 deletions
+10 -8
View File
@@ -1,9 +1,8 @@
import json
import flask_testing
from api import create_app, db
from api.models.product import Material, Product
from api.models.inquiry import Inquiry
from api.models.designer import Designer
from api.models.product import Material, Product, Currencies
from api.models import Inquiry, Designer, Market
from api.lib import pwinty
@@ -24,9 +23,12 @@ class TestEndpoints(flask_testing.TestCase):
db.session.commit()
return material
def _add_inquiry(self, territory, product_group, price_retouch=100):
def _add_inquiry(self, product_group, price_retouch=100):
currency = Currencies(iso3char="SEK", exchange_rate=1)
db.session.add(currency)
market = Market(name="SE", vat=1.25, currency='SEK', price_adjustments=1)
inquiry = Inquiry(
territory=territory,
market=market,
product_group=product_group,
price_retouch=price_retouch,
)
@@ -192,20 +194,20 @@ class TestEndpoints(flask_testing.TestCase):
def test_inquiry_wallpaper(self):
self._add_material("standard-wallpaper", 1, 236)
self._add_material("premium-wallpaper", 1, 260)
self._add_inquiry(territory="SE", product_group="photo-wallpaper")
self._add_inquiry(product_group="photo-wallpaper")
response = self.client.get("/prices/inquiry/1?width=100&height=100")
self.assert200(response)
self.assertEqual("wallpaper", response.json["group"])
def test_inquiry_canvas(self):
self._add_material("standard-canvas", 2, 799.2)
self._add_inquiry(territory="SE", product_group="canvas")
self._add_inquiry(product_group="canvas")
response = self.client.get("/prices/inquiry/1?width=100&height=100")
self.assert200(response)
self.assertEqual("canvas", response.json["group"])
def test_inquiry_poster(self):
self._add_inquiry(territory="SE", product_group="poster")
self._add_inquiry(product_group="poster")
response = self.client.get("/prices/inquiry/1?width=100&height=100")
self.assert200(response)
self.assertEqual("poster", response.json["group"])