From: Alfredo Deza Date: Mon, 2 Dec 2013 22:01:34 +0000 (-0500) Subject: a wealth of tests for the better error reporting X-Git-Tag: v1.3.4~5^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f2e908842c0fab9907ea8e00075df377432988d;p=ceph-deploy.git a wealth of tests for the better error reporting Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/tests/unit/hosts/test_hosts.py b/ceph_deploy/tests/unit/hosts/test_hosts.py index 4f6d805..701171f 100644 --- a/ceph_deploy/tests/unit/hosts/test_hosts.py +++ b/ceph_deploy/tests/unit/hosts/test_hosts.py @@ -1,4 +1,5 @@ from pytest import raises +from mock import Mock, patch from ceph_deploy import exc from ceph_deploy import hosts @@ -23,6 +24,39 @@ class TestNormalized(object): assert result == 'redhat' +class TestHostGet(object): + + def make_fake_connection(self, platform_information=None): + get_connection = Mock() + get_connection.return_value = get_connection + get_connection.remote_module.platform_information = Mock( + return_value=platform_information) + return get_connection + + def test_get_unsupported(self): + fake_get_connection = self.make_fake_connection(('Solaris Enterprise', '', '')) + with patch('ceph_deploy.hosts.get_connection', fake_get_connection): + with raises(exc.UnsupportedPlatform): + hosts.get('myhost') + + def test_get_unsupported_message(self): + fake_get_connection = self.make_fake_connection(('Solaris Enterprise', '', '')) + with patch('ceph_deploy.hosts.get_connection', fake_get_connection): + with raises(exc.UnsupportedPlatform) as error: + hosts.get('myhost') + + assert error.value.__str__() == 'Platform is not supported: Solaris Enterprise ' + + def test_get_unsupported_message_release(self): + fake_get_connection = self.make_fake_connection(('Solaris', 'Tijuana', '12')) + with patch('ceph_deploy.hosts.get_connection', fake_get_connection): + with raises(exc.UnsupportedPlatform) as error: + hosts.get('myhost') + + assert error.value.__str__() == 'Platform is not supported: Solaris 12 Tijuana' + + + class TestGetDistro(object): def test_get_debian(self): @@ -51,8 +85,7 @@ class TestGetDistro(object): assert result.__name__.endswith('centos') def test_get_uknown(self): - with raises(exc.UnsupportedPlatform): - hosts._get_distro('Solaris') + assert hosts._get_distro('Solaris') is None def test_get_fallback(self): result = hosts._get_distro('Solaris', 'Debian')