There were places in Database, CmdReport, and CmdHelp that were using a File
object when only the Path interface was needed. This is some minor cleanup I
noticed while studying the File usage as part of preparating for converting to
AtomicFile.
This fixes an error I introduced in the recent code to avoid loading the
entire database. It only now appeared because I happened to run the test
suite on the first of the month.
Below is the error I was seeing:
$ test/delete.t
1..5
ok 1 - delete.t: Delete a single closed interval
ok 2 - delete.t: Delete an interval which encloses a month border
ok 3 - delete.t: Delete a mix of open/closed intervals
not ok 4 - delete.t: Delete a single open interval
# FAIL: AssertionError on file test/delete.t line 56 in test_delete_open:
# 'self.assertEqual(len(j), 1)':
# 0 != 1
ok 5 - delete.t: Delete an open interval that spans over an exclusion
The problem is that when there was one entry in the 2020-01.data file
and one in the 2020-02.data file, when I deleted the single one in the
2020-02.data file, the interator constructor was not updating the lines
iterator when moving to a new file.
Since the recent switch to python3, I've been noticing that some of the tests
have been aborting with the following error when I use LANG=en_US instead of
LANG=en_US.UTF-8:
UnicodeEncodeError: 'latin-1' codec can't encode character '\u0455' in position 57: ordinal not in range(256)
Arguably, I should run with a unicode locale while running the test, but it
*looks* to me like the original ѕ was not intended.
When some of the individual tests fail to run, the `make test` target would
still pass since test/problems would not return an error which could hide the
fact that there are problems in the test.
With this change, if you do not have the python dateutil package, you will now
get output like:
'test_totals.t' failed to run any tests.
Passed: 975
Failed: 1
Unexpected successes: 0
Skipped: 0
Expected failures: 0
Runtime: 4.83 seconds
Or, if you do not have UTF-8 encoding set in your language you will get
something like:
'track.t' failed to run all tests.
'stop.t' failed to run all tests.
'start.t' failed to run all tests.
'test_totals.t' failed to run all tests.
Passed: 941
Failed: 50
Unexpected successes: 0
Skipped: 0
Expected failures: 0
Runtime: 4.55 seconds
This test updates one of the existing tests to make sure that an non-synthetic
interval in addition with the synthetic intervals can be moved properly.
getIntervalsByIds will be used by commands that are loading complete database
currently when they really want a few intervals that the user specified by ID.
Related to issue #245
The getUntracked, called as part of the `timew gaps` command, is
normally looking at a relatively recent interval. We do not want to take
the performance hit of loading the entire database into memory when
processing this command.
Related to issue #245
The database class now separatly tracks tag information. So for the one
place where all the inclusions were iterated over in order to build up a
tag set, we now instead ask the database for this set directly.
Related to issue #245
This does not appear to be necessary anymore given that the database lines are
generated from intervals and are all well formed. Any open interval *should* be
at the end of the database.
Related to issue #245.
intervalSummarize is called at the end of most commands. The cost of parsing
all the lines in the database can be significant as the size of the database
grows.
Related to issue #245.
This allows the database to be treated as a single collection of strings, but
can be used to avoid loading the entire database when only interested in recent
entries.
Related to issue #245.
Not only does this eliminate the need to copy the stings to the caller, it will
also eliminate the need for any iterators over the entries in the Database from
having to hold a copy of the lines from the Datafile.
Related to #245.
Since the switch to python3, there is another method that starts with "test"
higher up in the stack which produces unhelpful file / line information on a
failed test like:
ERROR: CommandError on file /usr/lib/python3.6/unittest/case.py line 59 in testPartExecutor: 'yield':
This change restores the previous behavior from before the switch to python 3.