]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
a wealth of tests for the better error reporting 142/head
authorAlfredo Deza <alfredo.deza@inktank.com>
Mon, 2 Dec 2013 22:01:34 +0000 (17:01 -0500)
committerAlfredo Deza <alfredo.deza@inktank.com>
Mon, 2 Dec 2013 22:01:34 +0000 (17:01 -0500)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/tests/unit/hosts/test_hosts.py

index 4f6d805aa65bf4b5897f8c2bc3f237dc70dcfafe..701171f076f561d5963ca4c16417521003a22dc3 100644 (file)
@@ -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')