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