The list of notifications is diplayed with each item enclosed within an
horizontal line as for timeline. When a status is involved (when
notification type is "reblog" or "favourite"), we also display the full
status.
Closes#81.
When the left column contains wide characters (which occupy more than
one cell when printed to screen), padding to 30-characters with
"{:30}".format() does not work well. This happens for instance when the
display name contains unicode characters such as emojis.
We fix this by introducing a pad() function in utils module which uses
the wcwidth library (https://pypi.org/project/wcwidth/) to compute the
length of the text for the column. trunc() function is also adjusted to
optionally compute the length of the text to be truncated since, when
called from pad(), we now pre-compute this value.
We update test for timeline rendering so that the display name now
includes an emoji. (Without the fix, the test would not pass as left
column would be misaligned.)
Beautiful will does not parse HTML entities like `'` as we expect
and the previous logic of replacing this *after* HTML parsing occurred
did not produced expected results.
To illustrate this, we change data in "test_timeline" to include a
literal `'` as it sometimes occur in data returned by Mastodon API.
New HTML content is:
<p>The computer can't tell you the emotional story [...] </p>
Beautiful will parse this as as:
<p>The computer can&apost tell you the emotional story [...] </p>
which is not what we expect.
We fix this by replacing `'` *before* HTML parsing by Beautiful.
Since test data in "test_timeline" got updated we also add an extra
assertion checking that part of the content with a literal "'" is
(still) properly rendered.
According to the Python documentation[1]:
> Calls to unsetenv() don’t update os.environ, so it is actually
> preferable to delete items of os.environ.
It means that os.unsetenv is not enough to remove an entry from
os.environ. This is why the following test was failing:
os.unsetenv('XDG_CONFIG_HOME')
assert fn() == os.path.expanduser('~/.config/toot/config.json')
os.unsetenv did not influence the output of the subsequent call to
os.getenv() in get_config_file_path(). As a result the original value
was returned instead of the fallback value of '~/.config'.
This bug was discovered during porting toot to FreeBSD as the FreeBSD
Ports framework passes XDG_CONFIG_HOME to make's environment.
[1]: https://docs.python.org/3.6/library/os.html#os.unsetenv