Пример #1
0
 def test_no_file_out(self):
     tempdir = tempfile.mkdtemp()
     now = datetime.datetime(2010, 05, 01)
     e = util.raises(
         RuntimeError,
         timelog.clock_out,
         reason='test',
         log_path=os.path.join(tempdir, 'timelog'),
         _now=now,
         )
     assert str(e) == 'not clocked in'
     assert 'timelog' not in os.listdir(tempdir)
Пример #2
0
 def test_wrong_order(self):
     tempdir = tempfile.mkdtemp()
     with open(os.path.join(tempdir, 'timelog'), 'w') as f:
         f.write('i 2010/03/16 12:20:19 misc\n')
     now = datetime.datetime(2010, 03, 17)
     e = util.raises(
         RuntimeError,
         timelog.clock_in,
         reason='test',
         log_path=os.path.join(tempdir, 'timelog'),
         _now=now,
         )
     assert str(e) == "already clocked in"
     assert 'timelog' in os.listdir(tempdir)
     with open(os.path.join(tempdir, 'timelog')) as f:
         lines = f.readlines()
         assert lines == ['i 2010/03/16 12:20:19 misc\n']