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:
Rikard Bartholf
2017-01-17 11:42:26 +01:00
parent 5ad053a09b
commit 617c2daa06
4 changed files with 15 additions and 43 deletions
+8 -9
View File
@@ -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(