diff --git a/cinderclient/tests/unit/v1/test_services.py b/cinderclient/tests/unit/v1/test_services.py index e0bfa7779..bf3e26c1d 100644 --- a/cinderclient/tests/unit/v1/test_services.py +++ b/cinderclient/tests/unit/v1/test_services.py @@ -20,6 +20,11 @@ from cinderclient.v1 import services cs = fakes.FakeClient() +FAKE_SERVICE = {"host": "host1", + 'binary': 'cinder-volume', + "status": "enable", + "availability_zone": "nova"} + class ServicesTest(utils.TestCase): @@ -73,3 +78,14 @@ class ServicesTest(utils.TestCase): cs.assert_called('PUT', '/os-services/disable-log-reason', values) self.assertIsInstance(s, services.Service) self.assertEqual('disabled', s.status) + + def test___repr__(self): + """ + Unit test for Service.__repr__ + + Verify that one Service object can be printed. + """ + svs = services.Service(None, FAKE_SERVICE) + self.assertEqual( + "" % (FAKE_SERVICE['binary'], + FAKE_SERVICE['host']), repr(svs)) diff --git a/cinderclient/v1/services.py b/cinderclient/v1/services.py index 3bc4b3b43..b6faf0399 100644 --- a/cinderclient/v1/services.py +++ b/cinderclient/v1/services.py @@ -22,7 +22,7 @@ from cinderclient import base class Service(base.Resource): def __repr__(self): - return "" % self.service + return "" % (self.binary, self.host) class ServiceManager(base.ManagerWithFind):