PW-567 add the old canvas formula

This commit is contained in:
Martin
2016-10-31 17:57:11 +01:00
parent cbee61b564
commit bf9fc3ae5a
10 changed files with 352 additions and 35 deletions
+49
View File
@@ -0,0 +1,49 @@
import json
import flask_testing
from api import create_app, db
from api.models.product import Material, MaterialPrice
class TestEndpoints(flask_testing.TestCase):
def create_app(self):
return create_app('tests.config')
def setUp(self):
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
def _add_material(self, name, groupid, price):
material = Material(name=name)
material.material_price = MaterialPrice(price=price, groupid=groupid)
db.session.add(material)
db.session.commit()
return material
def test_canvas(self):
self._add_material('standard-canvas', 2, 799.9)
response = self.client.get(
'/prices/canvas?width=200&height=10&territory=SE')
self.assert200(response)
products = response.json['data']
for product in products:
if product['framed']:
self.assertEqual(150, product['width'])
self.assertEqual(40, product['height'])
self.assertEqual(1213, product['price'])
else:
self.assertEqual(200, product['width'])
self.assertEqual(20, product['height'])
self.assertEqual(400, product['price'])
def test_diy_frame(self):
response = self.client.get(
'/prices/diy-frame?width=200&height=50&territory=SE')
self.assert200(response)
product = response.json['data'][0]
self.assertEqual(150, product['width'], "it adjusts measurements")
self.assertEqual(50, product['height'])
self.assertEqual(924, product['price'])