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.
right, I'll fix when I move it internal