diff --git a/saharaclient/api/node_group_templates.py b/saharaclient/api/node_group_templates.py index 90c1b4da..0eaf80bb 100644 --- a/saharaclient/api/node_group_templates.py +++ b/saharaclient/api/node_group_templates.py @@ -127,3 +127,7 @@ class NodeGroupTemplateManager(base.ResourceManager): def delete(self, ng_template_id): """Delete a Node Group Template.""" self._delete('/node-group-templates/%s' % ng_template_id) + + def export(self, ng_template_id): + """Export a Node Group Template.""" + return self._get('/node-group-templates/%s/export' % ng_template_id) diff --git a/saharaclient/tests/unit/base.py b/saharaclient/tests/unit/base.py index c2cd255e..6d95f6a4 100644 --- a/saharaclient/tests/unit/base.py +++ b/saharaclient/tests/unit/base.py @@ -35,6 +35,11 @@ class BaseTestCase(testtools.TestCase): for key, value in body.items(): self.assertEqual(value, getattr(obj, key)) + def assertDictsEqual(self, dict1, dict2): + self.assertEqual(len(dict1), len(dict2)) + for key in dict1: + self.assertEqual(dict1[key], dict2[key]) + class TestResource(base.Resource): resource_name = 'Test Resource' diff --git a/saharaclient/tests/unit/test_node_group_templates.py b/saharaclient/tests/unit/test_node_group_templates.py index 99ef5a0d..13a75514 100644 --- a/saharaclient/tests/unit/test_node_group_templates.py +++ b/saharaclient/tests/unit/test_node_group_templates.py @@ -145,3 +145,12 @@ class NodeGroupTemplateTest(base.BaseTestCase): self.assertEqual(update_url, self.responses.last_request.url) self.assertEqual(unset_json, json.loads(self.responses.last_request.body)) + + def test_node_group_template_export(self): + url = self.URL + '/node-group-templates/id/export' + self.responses.get(url, json={'node_group_template': self.body}) + resp = self.client.node_group_templates.export('id') + + self.assertEqual(url, self.responses.last_request.url) + self.assertIsInstance(resp, ng.NodeGroupTemplate) + self.assertDictsEqual(self.body, resp.__dict__[u'node_group_template'])