Mock smtplib. Skip mysql tests if no DB.

- Mock out smtplib.SMTP so we don't send email during tests
- Change test_lib to handle test skips in setUp
- Skip mysql tests if port == 0, this seems to be the best indicator of whether
  you have configured a DB or not. This avoids tests failing if you have the
  mysql client library installed but no actual database present.
I just realized, the port must not be set here. If we omit it, it will just use a local connection. We need to try to connect, catch the error and move on if it doesn't work.