From 7836c923ae45cbed8c8a31e3694c8f5afecc8cc3 Mon Sep 17 00:00:00 2001 From: jonnary Date: Thu, 27 Oct 2016 18:37:35 +0800 Subject: [PATCH] Add unit test in test_cluster_update_cluster_bad_status test_cluster_update_cluster_bad_status hasn't coverage line "if cluster.status == cluster.ERROR:" in cluster_update. When we do some chages in which this line referenced it will cause api test fail and waste time to find this line. Change-Id: Ibe2b30506697c84922827d1fde0f0bec7b6f5ed7 --- senlin/tests/unit/engine/service/test_clusters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/senlin/tests/unit/engine/service/test_clusters.py b/senlin/tests/unit/engine/service/test_clusters.py index 6dce0d24d..1fcbfac5f 100644 --- a/senlin/tests/unit/engine/service/test_clusters.py +++ b/senlin/tests/unit/engine/service/test_clusters.py @@ -1111,10 +1111,12 @@ class ClusterTest(base.SenlinTestCase): def test_cluster_update2_cluster_bad_status(self, mock_find, mock_load): x_obj = mock.Mock() mock_find.return_value = x_obj - mock_load.return_value = mock.Mock(status='ERROR', ERROR='ERROR') + x_cluster = mock.Mock(status='ERROR', ERROR='ERROR') + mock_load.return_value = x_cluster req = {'identity': 'CLUSTER', 'name': 'new-name'} self._prepare_request(req) + self.assertEqual(consts.CS_ERROR, x_cluster.status) ex = self.assertRaises(rpc.ExpectedException, self.eng.cluster_update2, self.ctx, req)