Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/datapipeline/test_listrunsformatter.py
1569 views
1
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
import difflib
15
16
from awscli.testutils import mock, unittest
17
from awscli.customizations.datapipeline.listrunsformatter \
18
import ListRunsFormatter
19
from awscli.compat import StringIO
20
21
22
class TestListRunsFormatter(unittest.TestCase):
23
def setUp(self):
24
self.formatter = ListRunsFormatter(mock.Mock(query=None))
25
self.stream = StringIO()
26
27
def assert_data_renders_to(self, data, table):
28
self.formatter('list-runs', data, stream=self.stream)
29
rendered = self.stream.getvalue()
30
31
differ = difflib.Differ()
32
diff = differ.compare(table.splitlines(1), rendered.splitlines(1))
33
34
self.assertEqual(table, rendered, msg='\n' + '\n'.join(diff))
35
36
def test_empty(self):
37
self.assert_data_renders_to(
38
[],
39
" Name Scheduled Start Status \n" # noqa
40
" ID Started Ended \n" # noqa
41
"---------------------------------------------------------------------------------------------------\n") # noqa
42
43
def test_single_row(self):
44
self.assert_data_renders_to(
45
[{
46
'@componentParent': 'parent',
47
'@id': 'id',
48
'@scheduledStartTime': 'now',
49
'@status': 'status',
50
'@actualStartTime': 'actualStartTime',
51
'@actualEndTime': 'actualEndTime',
52
}],
53
" Name Scheduled Start Status \n" # noqa
54
" ID Started Ended \n" # noqa
55
"---------------------------------------------------------------------------------------------------\n" # noqa
56
" 1. parent now status \n" # noqa
57
" id actualStartTime actualEndTime \n" # noqa
58
"\n"
59
)
60
61