Signed-off-by: Dmitry Borodaenko <angdraug@gmail.com>
def remote_shortname(socket):
"""
Obtains remote hostname of the socket and cuts off the domain part
- if it's FQDN.
+ of its FQDN.
"""
return socket.gethostname().split('.', 1)[0]
result = hosts.mock_calls
assert result == expected
- def test_remote_shortname(self):
+ def test_remote_shortname_fqdn(self):
socket = Mock()
socket.gethostname.return_value = 'host.f.q.d.n'
assert remote_shortname(socket) == 'host'
+ def test_remote_shortname_host(self):
socket = Mock()
socket.gethostname.return_value = 'host'
assert remote_shortname(socket) == 'host'