P5-2777 add poster price calculations

This commit is contained in:
Martin
2018-10-04 16:18:35 +02:00
parent c798a4da0b
commit 04187803af
5 changed files with 266 additions and 7 deletions
+16
View File
@@ -247,3 +247,19 @@ class TestPrice(unittest2.TestCase):
def test_package_price(self):
self.assertEqual(800, package_price(150, 40, market=us))
self.assertEqual(0, package_price(150, 40, market=sweden))
def test_poster_cm2_price(self):
self.assertEqual(0.08399104, poster_cm2_price(1))
self.assertEqual(0.08310400000000001, poster_cm2_price(100))
self.assertEqual(0.07504000000000001, poster_cm2_price(1000))
self.assertEqual(0.0336, poster_cm2_price(10000))
self.assertEqual(0.028, poster_cm2_price(100000))
def test_poster_price(self):
self.assertEqual(287, poster_price(width=30, height=40, hanger=True, market=sweden))
self.assertEqual(168, poster_price(width=30, height=40, hanger=False, market=sweden))
self.assertEqual(152, poster_price(width=125, height=40, market=us), 'extra cost for large packages')
def test_poster_hanger_price(self):
self.assertEqual(182, poster_hanger_price(30, market=sweden))
self.assertEqual(438, poster_hanger_price(150, market=sweden))
+29
View File
@@ -152,6 +152,35 @@ class TestEndpoints(flask_testing.TestCase):
self.assertEqual(50, product['height'])
self.assertAlmostEqual(731.25, product['price'], places=2)
def test_poster(self):
response = self.client.get('/prices/poster?width=50&height=30&territory=SE')
self.assert200(response)
expected = [
{
'hanger': True,
'height': 30,
'price': 337.0,
'price_excl_vat': 269.6,
'width': 50
},
{
'hanger': False,
'height': 30,
'price': 168.0,
'price_excl_vat': 134.4,
'width': 50
}
]
self.assertEqual(expected, response.json['data'])
def test_poster_hanger(self):
response = self.client.get('/prices/poster-hanger?width=50&territory=SE')
self.assert200(response)
product = response.json['data'][0]
self.assertEqual(231.5, product['price'])
self.assertEqual(185.2, product['price_excl_vat'])
self.assertEqual(50, product['width'])
def test_inquiry_wallpaper(self):
self._add_material('standard-wallpaper', 1, 236)
self._add_material('premium-wallpaper', 1, 260)