Ejemplo n.º 1
0
 def testGenerateMonthlyData(self):
     jsDatasetGenerator = JSDatasetGenerator()
     jsDatasetGenerator.setDataParser(self.dataParser)
     
     #    [ [ DateUTC(YYY, MM, DD), [Rx %] , [Tx %] ], 
     #      [ DateUTC(YYY, MM, DD), [Rx %] , [Tx %] ], ...]
     #
     #    To create the desired shape this are the proportions:
     #
     #        [0, 50, 30, 100, 30, 50, 0 ]
     #
     # Assuming the dummy data file to contain the following:
     #
     # m;1;1334980780;1024;2048;0;0;1
     # m;2;1334982490;8192;4096;0;0;1
     #
     expectedDataSet = ([['Date.UTC(2012,3,21,4,59,40)', 'Date.UTC(2012,3,21,5,28,10)'],
                         [1024.0, 8192.0], [2048.0, 4096.0],
                         [[0.0, 6.25, 3.75, 12.5, 3.75, 6.25, 0.0],
                          [0.0, 50.0, 30.0, 100.0, 30.0, 50.0, 0.0]],
                         [[0.0, 12.5, 7.5, 25.0, 7.5, 12.5, 0.0],
                          [0.0, 25.0, 15.0, 50.0, 15.0, 25.0, 0.0]]])
     
     jsDatasetGenerator.setJSFilePath("/dev/null")
     calculatedDataSet = jsDatasetGenerator.generateMonthlyDataSet()
     
     expectedDataSet = str(expectedDataSet).replace("'", "").replace("\"", "")
     calculatedDataSet = str(calculatedDataSet).replace("'", "").replace("\"", "")
     #print(expectedDataSet)
     #print(calculatedDataSet)
     
     self.assertEqual(expectedDataSet, calculatedDataSet,
                      "Calculated data do not match expected data set!")
Ejemplo n.º 2
0
 def main(self):
     dataParser = DataParser()
     dataParser.setVnStatHandler(VnStatHandler())
     
     jsDataGenerator = JSDatasetGenerator()
     jsDataGenerator.setDataParser(dataParser)
     
     jsDataGenerator.generateUpdateTimeRecord()
     jsDataGenerator.generateHourlyDataSet()
     jsDataGenerator.generateDailyDataSet()
     jsDataGenerator.generateMonthlyDataSet()
     jsDataGenerator.generateTopTenDaysDataSet()
     
     jsDataGenerator.cleanup()