Beispiel #1
0
 def test_pair_2(self):
     gifts, budget = validate(self.pricefile, 2300)
     selected_gifts = find_gifts_pair(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Paperback Book")
     self.assertEqual(selected_gifts[0]['price'], 700)
     self.assertEqual(selected_gifts[1]['name'], "Headphones")
     self.assertEqual(selected_gifts[1]['price'], 1400)
Beispiel #2
0
 def test_pair_3(self):
     gifts, budget = validate(self.pricefile, 10000)
     selected_gifts = find_gifts_pair(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Earmuffs")
     self.assertEqual(selected_gifts[0]['price'], 2000)
     self.assertEqual(selected_gifts[1]['name'], "Bluetooth Stereo")
     self.assertEqual(selected_gifts[1]['price'], 6000)
Beispiel #3
0
 def test_pair_1(self):
     gifts, budget = validate(self.pricefile, 2500)
     selected_gifts = find_gifts_pair(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Candy Bar")
     self.assertEqual(selected_gifts[0]['price'], 500)
     self.assertEqual(selected_gifts[1]['name'], "Earmuffs")
     self.assertEqual(selected_gifts[1]['price'], 2000)
Beispiel #4
0
 def test_trio_2(self):
     gifts, budget = validate(self.pricefile, 3100)
     selected_gifts = find_gifts_trio(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Paperback Book")
     self.assertEqual(selected_gifts[0]['price'], 700)
     self.assertEqual(selected_gifts[1]['name'], "Detergent")
     self.assertEqual(selected_gifts[1]['price'], 1000)
     self.assertEqual(selected_gifts[2]['name'], "Headphones")
     self.assertEqual(selected_gifts[2]['price'], 1400)
Beispiel #5
0
 def test_trio_1(self):
     gifts, budget = validate(self.pricefile, 2500)
     selected_gifts = find_gifts_trio(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Candy Bar")
     self.assertEqual(selected_gifts[0]['price'], 500)
     self.assertEqual(selected_gifts[1]['name'], "Paperback Book")
     self.assertEqual(selected_gifts[1]['price'], 700)
     self.assertEqual(selected_gifts[2]['name'], "Detergent")
     self.assertEqual(selected_gifts[2]['price'], 1000)
Beispiel #6
0
 def test_trio_3(self):
     gifts, budget = validate(self.pricefile, 10000)
     selected_gifts = find_gifts_trio(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Headphones")
     self.assertEqual(selected_gifts[0]['price'], 1400)
     self.assertEqual(selected_gifts[1]['name'], "Earmuffs")
     self.assertEqual(selected_gifts[1]['price'], 2000)
     self.assertEqual(selected_gifts[2]['name'], "Bluetooth Stereo")
     self.assertEqual(selected_gifts[2]['price'], 6000)
Beispiel #7
0
 def test_trio_3(self):
     gifts, budget = validate(self.pricefile, 2900)
     selected_gifts = find_gifts_trio(gifts, budget)
     self.assertEqual(selected_gifts[0]['name'], "Candy Bar")
     self.assertEqual(selected_gifts[0]['price'], 500)
     self.assertEqual(selected_gifts[1]['name'], "Detergent")
     self.assertEqual(selected_gifts[1]['price'], 1000)
     self.assertEqual(selected_gifts[2]['name'], "Headphones")
     self.assertEqual(selected_gifts[2]['price'], 1400)
Beispiel #8
0
 def test_pair_5(self):
     gifts, budget = validate(self.pricefile, 0)
     selected_gifts = find_gifts_pair(gifts, budget)
     self.assertFalse(selected_gifts)
Beispiel #9
0
 def test_validate1(self):
     try:
         validate(self.pricefile, 2500)
     except:
         self.fail("Should not fail, valid input!")
Beispiel #10
0
 def test_trio_4(self):
     gifts, budget = validate(self.pricefile, 1100)
     selected_gifts = find_gifts_trio(gifts, budget)
     self.assertFalse(selected_gifts)