Allow to configure a default value for <range> in report command
This addresses #394 which was recently opened by me.
TODOs:
- test(s)
- extend documentation
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 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.
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.
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
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.
This has been implemented in 5265b26e.