class TestTcxParserDump(unittest.TestCase): def setUp(self): self.test_file_name = "test_9trackpoints.tcx" self.test_file_name2 = "test_all_trackpoints.tcx" self.expected_results = [[0, 264, 91, u'test_9trackpoints'], [1, 275, 92, u'test_9trackpoints'], [2, 280, 94, u'test_9trackpoints']] log.config =OrderedDict([('now',12),('type',10),('class',15),('funcname',15),('module',20),('msg',-1)]) self.tcxparser = TcxParser(TEST_FILES,databasename="foo",tablename="foo") self.tcxparser.process_files(summation_type="avg",bucket_size=3) def test_(self): expected_results = [['0','0', '264', '91', '"test_9trackpoints"'], ['1','1', '275', '92', '"test_9trackpoints"'], ['2','2', '280', '94', '"test_9trackpoints"']] self.assertListEqual(self.tcxparser.dump(self.test_file_name,"avg"), expected_results) def test_bad_file(self): self.assertListEqual([],self.tcxparser.dump("foobar.tcx","avg")) def test_bad_timeseries_type(self): self.assertListEqual([],self.tcxparser.dump("test_9trackpoints.tcx","foo"))
class TestTcxParserDumpMultiFiles(unittest.TestCase): def setUp(self): self.test_file_name = "test_9trackpoints.tcx" self.test_file_name2 = "test_all_trackpoints.tcx" self.expected_results = [[0, 264, 91, u'test_9trackpoints'], [1, 275, 92, u'test_9trackpoints'], [2, 280, 94, u'test_9trackpoints'], [0, 264, 91, u'test_all_trackpoints'], [1, 275, 92, u'test_all_trackpoints'], [2, 280, 94, u'test_all_trackpoints'] ] log.config =OrderedDict([('now',12),('type',10),('class',15),('funcname',15),('module',20),('msg',-1)]) self.tcxparser = TcxParser(TEST_FILES,databasename="foo",tablename="foo") self.tcxparser.process_files(summation_type="avg",bucket_size=3) def test_(self): _dump = self.tcxparser.dump(summation_type="avg") self.assertEqual(_dump[3][0],'3')