Exemplo n.º 1
0
    def testSortingByTotal(self):
        seriesList = []
        config = [[1000, 100, 10, 0], [1000, 100, 10, 1]]
        for i, c in enumerate(config):
            seriesList.append(TimeSeries('Test(%d)' % i, 0, 0, 0, c))

        self.assertEquals(1110, functions.safeSum(seriesList[0]))

        result = functions.sortByTotal({}, seriesList)

        self.assertEquals(1111, functions.safeSum(result[0]))
        self.assertEquals(1110, functions.safeSum(result[1]))
Exemplo n.º 2
0
    def test_sorting_by_total(self):
        seriesList = []
        config = [[1000, 100, 10, 0], [1000, 100, 10, 1]]
        for i, c in enumerate(config):
            seriesList.append(TimeSeries('Test(%d)' % i, 0, 0, 0, c))

        self.assertEqual(1110, functions.safeSum(seriesList[0]))

        result = functions.sortByTotal({}, seriesList)

        self.assertEqual(1111, functions.safeSum(result[0]))
        self.assertEqual(1110, functions.safeSum(result[1]))
Exemplo n.º 3
0
 def test_safeSum_mixed(self):
     self.assertEqual(functions.safeSum([10,None,5,None]), 15)
Exemplo n.º 4
0
 def test_safeSum_all_None(self):
     self.assertEqual(functions.safeSum([None,None,None,None]), None)
Exemplo n.º 5
0
 def test_safeSum_all_numbers(self):
     self.assertEqual(functions.safeSum([1,2,3,4]), 10)
Exemplo n.º 6
0
 def test_safeSum_empty_list(self):
     self.assertEqual(functions.safeSum([]), None)
Exemplo n.º 7
0
 def test_safeSum_None(self):
     with self.assertRaises(TypeError):
         functions.safeSum(None)