summaryrefslogtreecommitdiff
path: root/heatclient/tests/unit/osc/v1/test_stack.py
diff options
context:
space:
mode:
Diffstat (limited to 'heatclient/tests/unit/osc/v1/test_stack.py')
-rw-r--r--heatclient/tests/unit/osc/v1/test_stack.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/heatclient/tests/unit/osc/v1/test_stack.py b/heatclient/tests/unit/osc/v1/test_stack.py
index 8239f48..54fe9be 100644
--- a/heatclient/tests/unit/osc/v1/test_stack.py
+++ b/heatclient/tests/unit/osc/v1/test_stack.py
@@ -777,6 +777,42 @@ class TestStackAdopt(TestStack):
self.assertRaises(exc.CommandError, self.cmd.take_action, parsed_args)
+class TestStackExport(TestStack):
+
+ columns = ['stack_name', 'stack_status', 'id']
+ data = ['my_stack', 'ABANDONED', '1234']
+
+ response = dict(zip(columns, data))
+
+ def setUp(self):
+ super(TestStackExport, self).setUp()
+ self.cmd = stack.ExportStack(self.app, None)
+ self.stack_client.export.return_value = self.response
+
+ def test_stack_export(self):
+ arglist = ['my_stack']
+ parsed_args = self.check_parser(self.cmd, arglist, [])
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ for column in self.columns:
+ self.assertIn(column, columns)
+ for datum in self.data:
+ self.assertIn(datum, data)
+
+ @mock.patch('heatclient.osc.v1.stack.open', create=True)
+ def test_stack_export_output_file(self, mock_open):
+ arglist = ['my_stack', '--output-file', 'file.json']
+ mock_open.return_value = mock.MagicMock(spec=io.IOBase)
+ parsed_args = self.check_parser(self.cmd, arglist, [])
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ mock_open.assert_called_once_with('file.json', 'w')
+ self.assertEqual([], columns)
+ self.assertIsNone(data)
+
+
class TestStackAbandon(TestStack):
columns = ['stack_name', 'stack_status', 'id']