def run_task(self, source):
        """Helper utility for running task under test"""

        def reformat(string):
            """Reformat string to make it like a TSV."""
            return textwrap.dedent(string).strip().replace(' ', '\t')

        with open(self.input_file, 'w') as fle:
            fle.write(reformat(source))

        task = TotalEventsReport(counts=self.input_file,
                                 report='fake_report')

        output_target = FakeTarget()
        task.output = MagicMock(return_value=output_target)
        task.run()
        data = output_target.buffer.read()

        result = pandas.read_csv(StringIO(data),
                                 na_values=['-'],
                                 index_col=False,
                                 header=None,
                                 names=['date', 'count'])

        return result
 def test_create_csv_entry(self):
     entry = TotalEventsReport.create_csv_entry('2014-01-02', '5000')
     self.assertEqual(entry, '2014-01-02,5000')
 def test_create_csv_header(self):
     header = TotalEventsReport.create_header()
     self.assertEqual(header, "date,event_count")