PW-570 inquiry price calculations

This commit is contained in:
Martin
2016-11-19 16:38:37 +01:00
parent 980aa8f88b
commit 4679dd2bbe
9 changed files with 371 additions and 15 deletions
+24 -1
View File
@@ -2,6 +2,7 @@ import json
import flask_testing
from api import create_app, db
from api.models.product import Material, MaterialPrice
from api.models.inquiry import Inquiry
class TestEndpoints(flask_testing.TestCase):
@@ -23,6 +24,13 @@ class TestEndpoints(flask_testing.TestCase):
db.session.commit()
return material
def _add_inquiry(self, territory, product_group, price_retouch=100):
inquiry = Inquiry(
territory=territory, product_group=product_group, price_retouch=price_retouch)
db.session.add(inquiry)
db.session.commit()
return inquiry
def test_wallpaper(self):
self._add_material('standard-wallpaper', 1, 236)
self._add_material('premium-wallpaper', 1, 260)
@@ -33,7 +41,7 @@ class TestEndpoints(flask_testing.TestCase):
self.assertEqual(2, len(products))
def test_canvas(self):
self._add_material('standard-canvas', 2, 799.9)
self._add_material('standard-canvas', 2, 799.2)
response = self.client.get(
'/prices/canvas?width=200&height=10&territory=SE')
self.assert200(response)
@@ -57,3 +65,18 @@ class TestEndpoints(flask_testing.TestCase):
self.assertEqual(150, product['width'], "it adjusts measurements")
self.assertEqual(50, product['height'])
self.assertAlmostEqual(923.857, product['price'], places=2)
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')
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')
response = self.client.get('/prices/inquiry/1?width=100&height=100')
self.assert200(response)
self.assertEqual('canvas', response.json['group'])