Add tests for show_resource function
This patch adds tests for sahara resources: - node group template - cluster template - cluster Change-Id: Ic6a6eb4e24d50b6e273c0699718a21ec0720631a
This commit is contained in:
parent
8afd8d0e05
commit
02df1fc657
|
@ -52,6 +52,7 @@ class FakeCluster(object):
|
|||
self.name = "super-cluster"
|
||||
self.info = {"HDFS": {"NameNode": "hdfs://hostname:port",
|
||||
"Web UI": "http://host_ip:port"}}
|
||||
self.to_dict = lambda: {"cluster": "info"}
|
||||
|
||||
|
||||
class SaharaClusterTest(common.HeatTestCase):
|
||||
|
@ -171,7 +172,8 @@ class SaharaClusterTest(common.HeatTestCase):
|
|||
cluster._resolve_attribute('info'))
|
||||
self.assertEqual(self.fake_cl.status,
|
||||
cluster._resolve_attribute('status'))
|
||||
self.assertEqual(2, self.cl_mgr.get.call_count)
|
||||
self.assertEqual({"cluster": "info"}, cluster.FnGetAtt('show'))
|
||||
self.assertEqual(3, self.cl_mgr.get.call_count)
|
||||
|
||||
def test_cluster_resource_mapping(self):
|
||||
cluster = self._init_cluster(self.t)
|
||||
|
|
|
@ -88,12 +88,14 @@ class FakeNodeGroupTemplate(object):
|
|||
def __init__(self):
|
||||
self.id = "some_ng_id"
|
||||
self.name = "test-cluster-template"
|
||||
self.to_dict = lambda: {"ng-template": "info"}
|
||||
|
||||
|
||||
class FakeClusterTemplate(object):
|
||||
def __init__(self):
|
||||
self.id = "some_ct_id"
|
||||
self.name = "node-group-template"
|
||||
self.to_dict = lambda: {"cluster-template": "info"}
|
||||
|
||||
|
||||
class SaharaNodeGroupTemplateTest(common.HeatTestCase):
|
||||
|
@ -230,6 +232,12 @@ class SaharaNodeGroupTemplateTest(common.HeatTestCase):
|
|||
name = self.ngt_mgr.create.call_args[0][0]
|
||||
self.assertIn('-nodegroup-', name)
|
||||
|
||||
def test_ngt_show_resource(self):
|
||||
ngt = self._create_ngt(self.t)
|
||||
self.ngt_mgr.get.return_value = self.fake_ngt
|
||||
self.assertEqual({"ng-template": "info"}, ngt.FnGetAtt('show'))
|
||||
self.ngt_mgr.get.assert_called_once_with('some_ng_id')
|
||||
|
||||
|
||||
class SaharaClusterTemplateTest(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
|
@ -323,3 +331,9 @@ class SaharaClusterTemplateTest(common.HeatTestCase):
|
|||
self.assertEqual(self.fake_ct.id, ct.resource_id)
|
||||
name = self.ct_mgr.create.call_args[0][0]
|
||||
self.assertIn('-clustertemplate-', name)
|
||||
|
||||
def test_ct_show_resource(self):
|
||||
ct = self._create_ct(self.t)
|
||||
self.ct_mgr.get.return_value = self.fake_ct
|
||||
self.assertEqual({"cluster-template": "info"}, ct.FnGetAtt('show'))
|
||||
self.ct_mgr.get.assert_called_once_with('some_ct_id')
|
||||
|
|
Loading…
Reference in New Issue