示例#1
0
 def test_Reports_categorized_report_includes_tags(self):
     rp = Reports(self.tw, style='categorized')
     txt = StringIO()
     rp.weekly_report(txt, '*****@*****.**', 'me')
     self.assertIn('Time spent in each area', txt.getvalue())
     txt = StringIO()
     rp.monthly_report(txt, '*****@*****.**', 'me')
     self.assertIn('Time spent in each area', txt.getvalue())
示例#2
0
    def test_Reports__report_tags(self):
        rp = Reports(self.tw)
        txt = StringIO()
        # use same tags as in tests above, so we know the totals
        rp._report_tags(txt, ['meeting', 'hpc'])
        self.assertEqual(
            txt.getvalue().strip(),
            textwrap.dedent("""
            Time spent in each area:

              hpc          5:04
              meeting      1:41

            Note that area totals may not add up to the period totals,
            as each entry may be belong to multiple areas (or none at all).
            """).strip())
示例#3
0
    def test_Reports__report_tags(self):
        from gtimelog.timelog import Reports
        rp = Reports(self.tw)
        txt = StringIO()
        # use same tags as in tests above, so we know the totals
        rp._report_tags(txt, ['meeting', 'hpc'])
        self.assertEqual(
            txt.getvalue().strip(),
            textwrap.dedent("""
            Time spent in each area:

              hpc          5:04
              meeting      1:41

            Note that area totals may not add up to the period totals,
            as each entry may be belong to multiple areas (or none at all).
            """).strip())
示例#4
0
 def on_monthly_report_activate(self, widget):
     """File -> Monthly Report"""
     reports = Reports(self.monthly_window())
     if self.settings.report_style == 'plain':
         report = reports.monthly_report_plain
     elif self.settings.report_style == 'categorized':
         report = reports.monthly_report_categorized
     else:
         report = reports.monthly_report_plain
     self.mail(report)
示例#5
0
 def on_last_month_report_activate(self, widget):
     """File -> Monthly Report for Last Month"""
     day = self.timelog.day - datetime.timedelta(self.timelog.day.day)
     reports = Reports(self.monthly_window(day=day))
     if self.settings.report_style == 'plain':
         report = reports.monthly_report_plain
     elif self.settings.report_style == 'categorized':
         report = reports.monthly_report_categorized
     else:
         report = reports.monthly_report_plain
     self.mail(report)
示例#6
0
 def on_weekly_report_activate(self, widget):
     """File -> Weekly Report"""
     day = self.timelog.day
     reports = Reports(self.weekly_window(day=day))
     if self.settings.report_style == 'plain':
         report = reports.weekly_report_plain
     elif self.settings.report_style == 'categorized':
         report = reports.weekly_report_categorized
     else:
         report = reports.weekly_report_plain
     self.mail(report)
示例#7
0
 def on_previous_month_report_activate(self, widget):
     """File -> Monthly Report for a Previous Month"""
     day = self.choose_date()
     if day:
         reports = Reports(self.monthly_window(day=day))
         if self.settings.report_style == 'plain':
             report = reports.monthly_report_plain
         elif self.settings.report_style == 'categorized':
             report = reports.monthly_report_categorized
         else:
             report = reports.monthly_report_plain
         self.mail(report)
示例#8
0
 def on_custom_range_report_activate(self, widget):
     """File -> Report for a Custom Date Range"""
     min, max = self.choose_date_range()
     if min and max:
         reports = Reports(self.range_window(min, max))
         self.mail(reports.custom_range_report_categorized)
示例#9
0
 def on_previous_day_report_activate(self, widget):
     """File -> Daily Report for a Previous Day"""
     day = self.choose_date()
     if day:
         reports = Reports(self.timelog.window_for_day(day))
         self.mail(reports.daily_report)
示例#10
0
 def on_yesterdays_report_activate(self, widget):
     """File -> Daily Report for Yesterday"""
     day = self.timelog.day - datetime.timedelta(1)
     reports = Reports(self.timelog.window_for_day(day))
     self.mail(reports.daily_report)
示例#11
0
 def on_daily_report_activate(self, widget):
     """File -> Daily Report"""
     reports = Reports(self.timelog.window)
     self.mail(reports.daily_report)
示例#12
0
 def report(self, method, window):
     output = StringIO()
     reports = Reports(window)
     report = getattr(reports, method)
     report(output, self.email, self.who)
     return output.getvalue()
示例#13
0
 def test_Reports_monthly_report_includes_tags(self):
     rp = Reports(self.tw)
     txt = StringIO()
     rp.monthly_report(txt, '*****@*****.**', 'me')
     self.assertIn('Time spent in each area', txt.getvalue())