Path: blob/develop/tests/unit/customizations/datapipeline/test_listrunsformatter.py
1569 views
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.1213import difflib1415from awscli.testutils import mock, unittest16from awscli.customizations.datapipeline.listrunsformatter \17import ListRunsFormatter18from awscli.compat import StringIO192021class TestListRunsFormatter(unittest.TestCase):22def setUp(self):23self.formatter = ListRunsFormatter(mock.Mock(query=None))24self.stream = StringIO()2526def assert_data_renders_to(self, data, table):27self.formatter('list-runs', data, stream=self.stream)28rendered = self.stream.getvalue()2930differ = difflib.Differ()31diff = differ.compare(table.splitlines(1), rendered.splitlines(1))3233self.assertEqual(table, rendered, msg='\n' + '\n'.join(diff))3435def test_empty(self):36self.assert_data_renders_to(37[],38" Name Scheduled Start Status \n" # noqa39" ID Started Ended \n" # noqa40"---------------------------------------------------------------------------------------------------\n") # noqa4142def test_single_row(self):43self.assert_data_renders_to(44[{45'@componentParent': 'parent',46'@id': 'id',47'@scheduledStartTime': 'now',48'@status': 'status',49'@actualStartTime': 'actualStartTime',50'@actualEndTime': 'actualEndTime',51}],52" Name Scheduled Start Status \n" # noqa53" ID Started Ended \n" # noqa54"---------------------------------------------------------------------------------------------------\n" # noqa55" 1. parent now status \n" # noqa56" id actualStartTime actualEndTime \n" # noqa57"\n"58)596061