Exemplo n.º 1
0
 def testpercentsToCount2(self):    
     #test with total as a range, percentages add to less than 100
     self.fruit = {'apples':20, 'oranges':15, 'banana':25}
     result = createItems.percentsToCount([0,1,2,3,4,5,6,7,8,9], self.fruit)
     self.assertEqual(result, {'apples': [0, 1], 
                               'oranges': [2], 
                               'banana': [3, 4]})
Exemplo n.º 2
0
 def testpercentsToCount3(self):    
     #test with total as an integer, percentages add to 100
     self.fruit={'apples':50, 'oranges':25, 'banana':25}
     result = createItems.percentsToCount(20, self.fruit)
     self.assertEqual(result, {'apples': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 
                               'oranges': [10, 11, 12, 13, 14], 
                               'banana': [15, 16, 17, 18, 19]})
Exemplo n.º 3
0
 def testpercentsToCount1(self):
     self.fruit = {'apples':20, 'oranges':15, 'banana':25}
     #test with total as an integer, percentages add to less than 100
     result = createItems.percentsToCount(20, self.fruit)
     self.assertEqual(result, {'apples': [0, 1, 2, 3], 
                               'oranges': [4, 5, 6], 
                               'banana': [7, 8, 9, 10, 11]})
Exemplo n.º 4
0
 def testpercentsToCount4(self):   
     #test with total as an integer, percentages sum to more than 100
     fruit={'apples':50, 'oranges':50, 'banana':50}
     result = createItems.percentsToCount(30, fruit)
     self.assertEqual(result, 
         {'apples': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 
        'oranges': [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 
                    29], 
        'banana': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]})
Exemplo n.º 5
0
 def testpercentsToCount3(self):
     #test with total as an integer, percentages add to 100
     self.fruit = {'apples': 50, 'oranges': 25, 'banana': 25}
     result = createItems.percentsToCount(20, self.fruit)
     self.assertEqual(
         result, {
             'apples': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
             'oranges': [10, 11, 12, 13, 14],
             'banana': [15, 16, 17, 18, 19]
         })
Exemplo n.º 6
0
 def testpercentsToCount2(self):
     #test with total as a range, percentages add to less than 100
     self.fruit = {'apples': 20, 'oranges': 15, 'banana': 25}
     result = createItems.percentsToCount([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                                          self.fruit)
     self.assertEqual(result, {
         'apples': [0, 1],
         'oranges': [2],
         'banana': [3, 4]
     })
Exemplo n.º 7
0
 def testpercentsToCount1(self):
     self.fruit = {'apples': 20, 'oranges': 15, 'banana': 25}
     #test with total as an integer, percentages add to less than 100
     result = createItems.percentsToCount(20, self.fruit)
     self.assertEqual(
         result, {
             'apples': [0, 1, 2, 3],
             'oranges': [4, 5, 6],
             'banana': [7, 8, 9, 10, 11]
         })
Exemplo n.º 8
0
 def testpercentsToCount4(self):
     #test with total as an integer, percentages sum to more than 100
     fruit = {'apples': 50, 'oranges': 50, 'banana': 50}
     result = createItems.percentsToCount(30, fruit)
     self.assertEqual(
         result, {
             'apples': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
             'oranges':
             [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
             'banana': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
         })