PW-622 Use column in materials table for getting prices
Squashed commit of the following: commit 801333b25a635c5fce12d937d6808894ef2475d3 Author: Martin <me.carlsson@gmail.com> Date: Tue Jan 3 10:59:45 2017 +0100 PW-622 divide by float commit 9e2c696751c28c017bcb452ea4349509ca787fd9 Author: Martin <me.carlsson@gmail.com> Date: Mon Jan 2 13:46:57 2017 +0100 PW-622 use new material_price column
This commit is contained in:
@@ -6,7 +6,7 @@ from tests.factories import DesignerFactory, ContractCustomerFactory, InquiryFac
|
||||
from api.models import market
|
||||
from api.models import Inquiry
|
||||
from api.models import Product
|
||||
from api.models.product import Material, MaterialPrice
|
||||
from api.models.product import Material
|
||||
|
||||
|
||||
sweden = market.from_territory('SE')
|
||||
@@ -37,14 +37,9 @@ piterra = ContractCustomerFactory(pricepremium=36.029411)
|
||||
designer_moomin = DesignerFactory()
|
||||
designer_moomin.pricepremium = 2
|
||||
|
||||
standard_wallpaper = Material(name='standard-wallpaper')
|
||||
standard_wallpaper.material_price = MaterialPrice(price=236)
|
||||
|
||||
premium_wallpaper = Material(name='premium-wallpaper')
|
||||
premium_wallpaper.material_price = MaterialPrice(price=260)
|
||||
|
||||
standard_canvas = Material(name='standard-canvas')
|
||||
standard_canvas.material_price = MaterialPrice(price=799.2)
|
||||
standard_wallpaper = Material(name='standard-wallpaper', price=23600)
|
||||
premium_wallpaper = Material(name='premium-wallpaper', price=26000)
|
||||
standard_canvas = Material(name='standard-canvas', price=79920)
|
||||
|
||||
|
||||
class TestPrice(unittest2.TestCase):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
import flask_testing
|
||||
from api import create_app, db
|
||||
from api.models.product import Material, MaterialPrice, Product
|
||||
from api.models.product import Material, Product
|
||||
from api.models.inquiry import Inquiry
|
||||
from api.models.designer import Designer
|
||||
|
||||
@@ -19,8 +19,7 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
db.drop_all()
|
||||
|
||||
def _add_material(self, name, groupid, price):
|
||||
material = Material(name=name)
|
||||
material.material_price = MaterialPrice(price=price, groupid=groupid)
|
||||
material = Material(name=name, price=price)
|
||||
db.session.add(material)
|
||||
db.session.commit()
|
||||
return material
|
||||
@@ -46,8 +45,8 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
return product
|
||||
|
||||
def test_wallpaper(self):
|
||||
self._add_material('standard-wallpaper', 1, 236)
|
||||
self._add_material('premium-wallpaper', 1, 260)
|
||||
self._add_material('standard-wallpaper', 1, 23600)
|
||||
self._add_material('premium-wallpaper', 1, 26000)
|
||||
response = self.client.get(
|
||||
'/prices/wallpaper?width=200&height=10&territory=SE')
|
||||
self.assert200(response)
|
||||
@@ -72,8 +71,8 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
self.assertEqual(expected, response.json['data'])
|
||||
|
||||
def test_wallpaper_with_product(self):
|
||||
self._add_material('standard-wallpaper', 1, 236)
|
||||
self._add_material('premium-wallpaper', 1, 260)
|
||||
self._add_material('standard-wallpaper', 1, 23600)
|
||||
self._add_material('premium-wallpaper', 1, 26000)
|
||||
designer = self._add_designer(4)
|
||||
product = self._add_product(designer)
|
||||
response = self.client.get(
|
||||
@@ -99,7 +98,7 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
self.assertEqual(expected, response.json['data'])
|
||||
|
||||
def test_canvas(self):
|
||||
self._add_material('standard-canvas', 2, 799.2)
|
||||
self._add_material('standard-canvas', 2, 79920)
|
||||
response = self.client.get(
|
||||
'/prices/canvas?width=200&height=10&territory=SE')
|
||||
self.assert200(response)
|
||||
@@ -126,7 +125,7 @@ class TestEndpoints(flask_testing.TestCase):
|
||||
self.assertEqual(expected, response.json['data'])
|
||||
|
||||
def test_canvas_with_product(self):
|
||||
self._add_material('standard-canvas', 2, 799.2)
|
||||
self._add_material('standard-canvas', 2, 79920)
|
||||
designer = self._add_designer(4)
|
||||
product = self._add_product(designer)
|
||||
response = self.client.get(
|
||||
|
||||
Reference in New Issue
Block a user