If a file called foo/.git exists, it isn't being escaped. This is a bug,
so add a test case for this and mark it xfail. This will be fixed in the
next commit.
mailer: Avoid bytes->Text->bytes conversion on mail body
Fixes formatting issue for emails where the body showed text as
b"blah blah".
This is caused by str.encode() being called on the body, which is
already of types bytes.
For clarification, also correct the typing specifiers to correctly
document the type on the message as bytes, not Text. (These specifiers
don't actually change the type of the parameters they refer to, but they
might show up as failures in lint checks, and may lead to incorrect code
docs).
mailer: Connect and disconnect from smtp service when sending emails
Since the importer is a long-running service, there can be a delay
between when the Mailer object is constructed and when it's used. This
can result in a "timeout after CONNECT from localhost[127.0.0.1]"
exactly 5 minutes later, shown in postfix's mail.log.
Along with the connect(), a quit() (SMTP's 'QUIT') is required to be
issued at the completion of the email. From testing, it appears that
under a number of different circumstances, smtplib can cope with it not
being explicitly called - for example it automatically calls it when the
smtplib object goes out of scope - however this is not guaranteed and it
is better practice to call it explicitly. Not doing so could
theoretically disrupt the mail submission, although I've not reproduced
this failure mechanism synthetically.
In practice it is unlikely that the importer would do anything
network-dependent before the network is available, but having
this might prevent weird failure scenarios.
Add support for executing self test in checked out tree.
git-ubuntu is expected to run in the snap environment, and the self test
is also. Building a snap just to run tests is painfully slow.
The solution here is to run the tests in an already-existing snap
environment. This does present a bit of a chicken-egg problem, but one
that is only exposed when we add new python dependencies to git-ubuntu.
git-ubuntu-self-test is modified to accept a TEST_TREE environment
variable and do the right thing in both snap environment and development
tree.
So now both of these work:
# test the snap installed git-ubuntu libraries.
$ git-ubuntu.self-test
# test the tree in "."
$ ./snap-wrappers/wrappers/git-ubuntu-self-test
Also done here:
* place 'SNAP_REVISION' and 'SNAP_VERSION' into environment.
these are just informative. And a useful message is printed
in the test output about the snap environment being used.
README.testing is updated with some documentation on how to run
git-ubuntu.self-test without building a snap and installing it first.