From: Alfredo Deza Date: Tue, 3 Sep 2013 15:02:45 +0000 (-0400) Subject: some tests for the new IP verification X-Git-Tag: v1.2.4~24^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=17e7f1491d51b60b662ef2863214c64f5a85df5d;p=ceph-deploy.git some tests for the new IP verification Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/tests/unit/util/test_arg_validators.py b/ceph_deploy/tests/unit/util/test_arg_validators.py index 82e181a..d9ef2a9 100644 --- a/ceph_deploy/tests/unit/util/test_arg_validators.py +++ b/ceph_deploy/tests/unit/util/test_arg_validators.py @@ -37,7 +37,9 @@ class TestHostName(object): def setup(self): self.fake_sock = Mock() self.fake_sock.gaierror = socket.gaierror + self.fake_sock.error = socket.error self.fake_sock.gethostbyname.side_effect = socket.gaierror + self.fake_sock.inet_aton.side_effect = socket.error def test_hostname_is_not_resolvable(self): hostname = arg_validators.Hostname(self.fake_sock) @@ -70,3 +72,12 @@ class TestHostName(object): hostname = arg_validators.Hostname(self.fake_sock) result = hostname('name:example.com') assert result == 'name:example.com' + + def test_hostname_must_be_an_ip(self): + self.fake_sock.gethostbyname = Mock() + self.fake_sock.inet_aton = Mock() + hostname = arg_validators.Hostname(self.fake_sock) + with raises(ArgumentError) as error: + hostname('0') + message = error.value.message + assert '0 must be a hostname' in message