timewarrior icon indicating copy to clipboard operation
timewarrior copied to clipboard

Allow to configure a default value for <range> in report command

Open chrko opened this issue 5 years ago • 5 comments

This addresses #394 which was recently opened by me.

TODOs:

  • test(s)
  • extend documentation

chrko avatar Oct 20 '20 20:10 chrko

Thanks for your contribution. I will review it as soon as possible.

Btw.: Do you still plan to add tests? They were on your TODO-list...

lauft avatar Oct 21 '20 05:10 lauft

@lauft Depends :D I haven't checked the testsuite yet how much effort this will be to test. If you consider this ready to merge, I would create a dedicated issue / pull request and start to work on a test case.

chrko avatar Oct 21 '20 14:10 chrko

There is no hurry, so I would prefer to have this PR complete with tests. I will try to come up with some pointers, else feel free to ask.

lauft avatar Oct 21 '20 17:10 lauft

I starting with the following approach to use self.t.faketime(…) to ensure always a consistent output, but this fails due the fact that faketime is not installed inside the docker container(s) yet. Any hint how to proceed?

diff --git a/test/extensions.t b/test/extensions.t
index bda4ab9..a662c26 100755
--- a/test/extensions.t
+++ b/test/extensions.t
@@ -56,6 +56,19 @@ class TestExtensions(TestCase):
         code, out, err = self.t('report ext')
         self.assertIn('test works', out)
 
+    def test_default_range(self):
+        self.t.add_default_extension('debug')
+        self.t.faketime('2006-01-02T15:04')
+
+        self.t.config('reports.debug.range', 'today')
+
+        code, out, err = self.t('report debug')
+
+        self.assertIn('temp.report.start', out)
+
+        print(out)
+
+
 
 if __name__ == "__main__":
     from simpletap import TAPTestRunner
diff --git a/test/test_extensions/debug b/test/test_extensions/debug
new file mode 100755
index 0000000..d868679
--- /dev/null
+++ b/test/test_extensions/debug
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec cat

chrko avatar Oct 21 '20 19:10 chrko

Do not use faketime, but instead relative datetimes. For example, see test/delete.t:46. In your example above, I would say you do not need to use the line self.t.faketime(...) at all.

Note that self.t.add_default_extention(...) installs from test/test_extensions which only contains ext_echo (and which may be unsuited as it only returns test works). Copy debug.py from ext into this directory to use it for testing.

lauft avatar Oct 21 '20 20:10 lauft

This has been implemented in 5265b26e.

lauft avatar Dec 30 '22 13:12 lauft