Beispiel #1
0
 def test_empty_dict(self):
     with self.assertRaises(Exception):
         profit({})
Beispiel #2
0
 def test_example_a(self):
     ip = {"cost_price": 32.67, "sell_price": 45.00, "inventory": 1200}
     self.assertAlmostEqual(profit(ip), 14796)
Beispiel #3
0
 def test_missing_inventory(self):
     with self.assertRaises(Exception):
         profit({"cost_price": 2.77, "sell_price": 7.95})
Beispiel #4
0
 def test_negative_inventory(self):
     ip = {"cost_price": 225.89, "sell_price": 550.00, "inventory": -100}
     with self.assertRaises(Exception):
         profit(ip)
Beispiel #5
0
 def test_missing_cost(self):
     with self.assertRaises(Exception):
         profit({"sell_price": 7.95, "inventory": 85001})
Beispiel #6
0
 def test_missing_sell(self):
     with self.assertRaises(Exception):
         profit({"cost_price": 2.77, "inventory": 85001})
Beispiel #7
0
 def testSuspended(self):
     self.assertEqual(profit.profit([]), 0)
Beispiel #8
0
 def test_example_c(self):
     ip = {"cost_price": 2.77, "sell_price": 7.95, "inventory": 8500}
     self.assertAlmostEqual(profit(ip), 44030)
Beispiel #9
0
 def testFlatlining(self):
     self.assertEqual(profit.profit([4, 4, 4]), 0)
Beispiel #10
0
 def testTank(self):
     self.assertEqual(profit.profit([4, 2, 1]), -1)
Beispiel #11
0
 def testProfitHighestSecondHalfDayNewHigh(self):
     self.assertEqual(profit.profit([2, 2, 5, 5, 1, 1, 7]), 6)
Beispiel #12
0
 def testProfitHighestFirstHalfNewLowsAfter(self):
     self.assertEqual(profit.profit([2, 2, 5, 5, 1, 2, 3]), 3)
Beispiel #13
0
 def testSkyrocket(self):
     self.assertEqual(profit.profit([1, 2, 5]), 4)