Exemple #1
0
    def test_execute(self):
        application = AggregateApp()
        application.read_command_line()
        application.read_configuration()

        # Verify the output files don't exist yet
        self.assertFalse(os.path.exists(self.output_filenames[0]))
        self.assertFalse(os.path.exists(self.output_filenames[1]))

        # Execute
        application.run()

        # Check that it has created two files
        self.assertTrue(os.path.exists(self.output_filenames[0]))
        self.assertTrue(os.path.exists(self.output_filenames[1]))

        # Check that the created time series are correct
        t = Timeseries()
        with open(self.output_filenames[0]) as f:
            t.read_file(f)
        self.assertEqual(t.timezone, 'EET (UTC+0200)')
        self.assertEqual(len(t), 1)
        self.assertAlmostEqual(t['2014-06-16 16:00'], 114.9, places=5)
        t = Timeseries()
        with open(self.output_filenames[1]) as f:
            t.read_file(f)
        self.assertEqual(t.timezone, '')
        self.assertEqual(len(t), 1)
        self.assertAlmostEqual(t['2014-06-17 16:00'], 50.8167, places=5)
Exemple #2
0
    def test_execute_error_message(self):
        application = AggregateApp()
        application.read_command_line()
        application.read_configuration()

        # Create a file that doesn't have timestamp rounding
        with open(self.filenames[0], 'w') as f:
            f.write("Location=23.78743 37.97385 4326\n"
                    "Time_step=10,0\n"
                    "Timestamp_offset=0,0\n"
                    "\n"
                    "2014-06-16 14:50,14.1,\n"
                    )

        # Execute
        try:
            application.run()
            self.assertTrue(False)
        except Exception as e:
            # Make sure the file name is included in the message
            self.assertTrue(self.filenames[0] in str(e))