Some users add a newline to their key, strip the key when checking if
it's already added.
Stop using regex (that didn't work) when checking if we already added a
hosts entry. Use a simple startswith() instead.
Switch to use MagicMock as it has support for iteration.
Change-Id: Ibeabbf1c4448933cdf274e6667c5a9493f3e5e37
Signed-off-by: Matthew Thode <mthode@mthode.org>