コード例 #1
0
    def testDividedFairly(self):
        pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 3.0, "Carol": 3.0, "Joyce": 3.0})
        #check that the right values are returned
        self.assertEqual(pay, {"Alice":90.0, "Bob": 90.0, "Carol": 90.0, "Joyce": 90.0})
        
        pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 3.0, "Carol": 6.0, "Joyce": 0.0})
        # Check that the right values are returned
        self.assertEqual(pay, {"Alice": 90.0, "Bob": 90.0, "Carol": 180.0, "Joyce": 0.0})

        pay = divide_pay(360.0, {"Alice": 0.0, "Bob": 0.0, "Carol": 0.0, "Joyce": 0.0})
        # Check that the right values are returned
        self.assertEqual(pay, {"Alice": 0, "Bob": 0, "Carol": 0, "Joyce": 0.0})
コード例 #2
0
 def testDividedFairly_zero_total(self):
     with self.assertRaises(ValueError):
         function_results = divide_pay(360, {
             "Alice": 0,
             "Bob": 0,
             "Carol": 0
         })
コード例 #3
0
 def testDividedFairly_amountZero(self):
     function_results = divide_pay(0, {
         "Alice": 0,
         "Bob": 3.0,
         "Carol": 6.0
     })
     self.assertEqual(function_results, {"Alice": 0, "Bob": 0, "Carol": 0})
コード例 #4
0
 def testDividedFairly(self):
     self.answers = {"Alice": 90, "Bob": 90, "Carol": 180}
     self.amount = 360.0
     self.staff_hours = {"Alice": 3.0, "Bob": 3.0, "Carol": 6.0}
         
     result_dict = divide_pay(self.amount,self.staff_hours)
     print "result_dict",result_dict
     
     for staff, result in self.answers.iteritems():
         print staff,result,result_dict[staff]
         self.assertEqual(result,result_dict[staff])
コード例 #5
0
 def test_divided_fairly(self):
     self.assertEqual(
         divide_pay(360.0, {
             "Alice": 3.0,
             "Bob": 3.0,
             "Carol": 6.0
         }), {
             "Alice": 90,
             "Bob": 90,
             "Carol": 180
         })
コード例 #6
0
 def testDividedFairly(self):
     function_results = divide_pay(360, {
         "Alice": 3.0,
         "Bob": 3.0,
         "Carol": 6.0
     })
     self.assertEqual(function_results, {
         "Alice": 90.0,
         "Bob": 90.0,
         "Carol": 180.0
     })
コード例 #7
0
 def test_zero_values(self):
     self.assertEqual(
         divide_pay(360.0, {
             "Alice": 3.0,
             "Bob": 3.0,
             "Carol": 0.0
         }), {
             "Alice": 120,
             "Bob": 240,
             "Carol": 0
         })
コード例 #8
0
    def testDividedFairly(self):
        pay = divide_pay(360.0, {
            "Alice": 3.0,
            "Bob": 3.0,
            "Carol": 3.0,
            "Joyce": 3.0
        })
        #check that the right values are returned
        self.assertEqual(pay, {
            "Alice": 90.0,
            "Bob": 90.0,
            "Carol": 90.0,
            "Joyce": 90.0
        })

        pay = divide_pay(360.0, {
            "Alice": 3.0,
            "Bob": 3.0,
            "Carol": 6.0,
            "Joyce": 0.0
        })
        # Check that the right values are returned
        self.assertEqual(pay, {
            "Alice": 90.0,
            "Bob": 90.0,
            "Carol": 180.0,
            "Joyce": 0.0
        })

        pay = divide_pay(360.0, {
            "Alice": 0.0,
            "Bob": 0.0,
            "Carol": 0.0,
            "Joyce": 0.0
        })
        # Check that the right values are returned
        self.assertEqual(pay, {"Alice": 0, "Bob": 0, "Carol": 0, "Joyce": 0.0})
コード例 #9
0
 def test_zero_hours_total(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {"Alice": 0.0, "Bob": 0.0, "Carol": 0.0})
コード例 #10
0
 def test_zero_hour_person(self):
     pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 6.0, "Carol": 0.0})
     self.assertEqual(pay, {"Alice": 120.0, "Bob": 240.0, "Carol": 0.0})
コード例 #11
0
 def testZeroHoursTotal(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {"Alice": 0.0, "Bob": 0.0, "Carol": 0.0})
コード例 #12
0
 def testZeroHourPerson(self):
     pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 6.0, "Carol": 0.0})
     self.assertEqual(pay, {"Alice": 120.0, "Bob": 240.0, "Carol": 0.0})
コード例 #13
0
 def test_zero_hour_person(self):
     self.assertEqual(divide_pay(360, {'Alice': 3.0, 'Bob': 6.0, 'Carol': 0.0}), {'Alice': 120.0, 'Bob': 240.0, 'Carol': 0.0})
コード例 #14
0
 def testDividedFairly_empty(self):
     with self.assertRaises(ValueError):
         function_results = divide_pay(360, {})
コード例 #15
0
 def test_divided_fairly(self):
     self.assertEqual(divide_pay(360.0, {"Alice": 3.0, "Bob": 3.0, "Carol": 6.0}), {"Alice": 90.0, "Bob": 90.0,
                                                                                    "Carol": 180.0})
コード例 #16
0
 def test_no_people(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {})
コード例 #17
0
 def test_divided_fairly(self):
     pay = divide_pay(30.0, {"Alice": 3.0, "Bob": 3.0, "Carol": 3.0})
     self.assertEqual(pay, {"Alice": 10.0, "Bob": 10.0, "Carol": 10.0})
コード例 #18
0
 def testDividedFairly(self):
     f = divide_pay(test_project_amount, test_project_hours)
     self.assertEqual(f, test_expected_pay)
コード例 #19
0
 def test_zero_hours(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {"Alice": 0.0, "Bob": 0.0, "Carol": 0.0})
コード例 #20
0
 def test_no_people(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {})
コード例 #21
0
 def testNegativeHours(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {"Alice": 3, "Bob": 6, "Carol": -6.0}) 
コード例 #22
0
 def testDividedFairly(self):
   staff_pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 3.0, "Carol": 6.0})
   self.assertEqual(staff_pay["Alice"], 90.0)
   self.assertEqual(staff_pay["Bob"], 90.0)
   self.assertEqual(staff_pay["Carol"], 180.0)
コード例 #23
0
 def testDividedPositive(self):
     pay = divide_pay(360,{"Alice":3.0, "Bob": 3.0, "Carol": 6.0})
     self.assertEqual(pay,{"Alice":90.0, "Bob": 90.0, "Carol": 180.0})
コード例 #24
0
 def test_zero_hours_total(self):
     with self.assertRaises(ValueError):
         pay = divide_pay(360.0, {'Alice': 0.0, 'Bob': 0.0, 'Carol': 0.0})
コード例 #25
0
 def testZeroHourPerson(self):  # way simpler to just call the function and then assertEqual to the answers.
     pay = divide_pay(360.0, {"Alice": 3.0, "Bob": 6.0, "Carol": 0.0})
     self.assertEqual(pay, {"Alice": 120.0, "Bob": 240.0, "Carol": 0.0}) 
コード例 #26
0
 def test_divided_fairly(self):
     self.assertEqual(divide_pay(360, {'Alice': 3.0, 'Bob': 3.0, 'Carol': 6.0}), {'Alice': 90, 'Bob': 90, 'Carol': 180})