コード例 #1
0
 def testExport(self):
     days = getDays()
     result = export(days, sampleFilePath('tmp_sample.ods'),
                     sampleFilePath('tmp_sample.ods'))
     self.assertTrue(
         result
     )  # Module pyexcel_ods must be installed. Install it via "pip install pyexcel_ods"
コード例 #2
0
 def testExport(self):
     days = getDays()
     f = io.StringIO()
     with redirect_stdout(f):
         # Module openpyxl must be installed. Install it via "pip install openpyxl"
         export(days, sampleFilePath('sample1.xlsx'),
                sampleFilePath('tmp_sample.xlsx'))
コード例 #3
0
    def test_pointless_category_switch(self):
        # Switch category
        output = run('timer', '2021-01-02 14:00', 'div')
        self.assertIn('You already have a timer running for Div', output)
        
        # Stop timer
        output = run('timer', '2021-01-02 16:00')
        self.assertIn('timer stopped', output)

        lastDay = getDays().days[-1]
        self.assertEqual(1, len(lastDay.work))
        self.assertEqual(lastDay.work[0].category, 'div')
コード例 #4
0
    def test_category_after_pause(self):
        # Pause
        output = run('pause', '2021-01-02 14:00')
        self.assertIn('Break started', output)
        
        # Stop pause
        output = run('pause', '2021-01-02 14:30')
        self.assertIn('Break ended', output)

        lastDay = getDays().days[-1]
        self.assertEqual(2, len(lastDay.work))
        # New work block should inherit category from before break 
        self.assertEqual(lastDay.work[0].category, 'div')
        self.assertEqual(lastDay.work[1].category, 'div')
コード例 #5
0
    def test_default_category(self):
        # Get sample data categories
        firstDay = getDays().days[0]
        self.assertEqual(firstDay.work[0].category, 'div')
        self.assertEqual(firstDay.work[1].category, 'test')


        # Stop ongoing timer to land at 0:00 overtime
        output = run('timer', '2021-01-02 16:00')
        self.assertIn('timer stopped', output)

        lastDay = getDays().days[-1]
        self.assertEqual(lastDay.work[0].category, 'div')

        # Start timer on next day
        output = run('timer', '2021-01-03 8:00')
        self.assertIn('timer started for Default', output)

        # Stop timer
        output = run('timer', '2021-01-03 17:00')
        self.assertIn('timer stopped', output)

        lastDay = getDays().days[-1]
        self.assertEqual(lastDay.work[0].category, 'default')
コード例 #6
0
    def test_switch_category(self):
        # Switch category
        output = run('timer', '2021-01-02 14:00', 'switched')
        self.assertIn('timer started for Switched', output)
        
        # Switch category again
        output = run('timer', '2021-01-02 15:00', 'another_switch')
        self.assertIn('timer started for Another Switch', output)
        
        # Stop timer
        output = run('timer', '2021-01-02 16:00')
        self.assertIn('timer stopped', output)

        lastDay = getDays().days[-1]
        self.assertEqual(lastDay.work[0].category, 'div')
        self.assertEqual(lastDay.work[1].category, 'switched')
        self.assertEqual(lastDay.work[2].category, 'another_switch')