/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_progress.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        task = self.make_task(None, view, 'reticulating splines', 5, 20)
68
68
        view.show_progress(task)
69
69
        self.assertEqual(
70
 
            '\r/ reticulating splines 5/20                                                    \r', out.getvalue())
 
70
'\r/ reticulating splines 5/20                                                    \r'
 
71
            , out.getvalue())
71
72
        view.clear()
72
73
        self.assertEqual(
73
 
            '\r/ reticulating splines 5/20                                                    \r' +
74
 
            '\r' + 79 * ' ' + '\r',
 
74
'\r/ reticulating splines 5/20                                                    \r'
 
75
            + '\r' + 79 * ' ' + '\r',
75
76
            out.getvalue())
76
77
 
77
78
    def test_render_progress_no_bar(self):
81
82
        task = self.make_task(None, view, 'reticulating splines', 5, 20)
82
83
        view.show_progress(task)
83
84
        self.assertEqual(
84
 
            '\r/ reticulating splines 5/20                                                    \r', out.getvalue())
 
85
'\r/ reticulating splines 5/20                                                    \r'
 
86
            , out.getvalue())
85
87
 
86
88
    def test_render_progress_easy(self):
87
89
        """Just one task and one quarter done"""
90
92
        task = self.make_task(None, view, 'reticulating splines', 5, 20)
91
93
        view.show_progress(task)
92
94
        self.assertEqual(
93
 
            '\r[####/               ] reticulating splines 5/20                               \r', out.getvalue())
 
95
'\r[####/               ] reticulating splines 5/20                               \r'
 
96
            , out.getvalue())
94
97
 
95
98
    def test_render_progress_nested(self):
96
99
        """Tasks proportionally contribute to overall progress"""
102
105
        # so we're in the first half of the main task, and half way through
103
106
        # that
104
107
        self.assertEqual(
105
 
            '[####-               ] reticulating splines:stage2 1/2                         ', view._render_line())
 
108
'[####-               ] reticulating splines:stage2 1/2                         '
 
109
            , view._render_line())
106
110
        # if the nested task is complete, then we're all the way through the
107
111
        # first half of the overall work
108
112
        task2.update('stage2', 2, 2)
109
113
        self.assertEqual(
110
 
            '[#########\\          ] reticulating splines:stage2 2/2                         ', view._render_line())
 
114
'[#########\\          ] reticulating splines:stage2 2/2                         '
 
115
            , view._render_line())
111
116
 
112
117
    def test_render_progress_sub_nested(self):
113
118
        """Intermediate tasks don't mess up calculation."""
123
128
        # progress indication, just a label; and the bottom one is half done,
124
129
        # so the overall fraction is 1/4
125
130
        self.assertEqual(
126
 
            '[####|               ] a:b:c 1/2                                               ', view._render_line())
 
131
'[####|               ] a:b:c 1/2                                               '
 
132
            , view._render_line())
127
133
 
128
134
    def test_render_truncated(self):
129
135
        # when the bar is too long for the terminal, we prefer not to truncate
134
140
        task_a.update('start_' + 'a' * 200 + '_end', 2000, 5000)
135
141
        line = view._render_line()
136
142
        self.assertEqual(
137
 
            '- start_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.. 2000/5000',
138
 
            line)
 
143
'- start_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.. 2000/5000',
 
144
           line) 
139
145
        self.assertEqual(len(line), 79)
140
146
 
 
147
 
141
148
    def test_render_with_activity(self):
142
149
        # if the progress view has activity, it's shown before the spinner
143
150
        out, view = self.make_view()
145
152
        view._last_transport_msg = '   123kB   100kB/s '
146
153
        line = view._render_line()
147
154
        self.assertEqual(
148
 
            '   123kB   100kB/s /                                                           ',
149
 
            line)
 
155
'   123kB   100kB/s /                                                           ',
 
156
           line) 
150
157
        self.assertEqual(len(line), 79)
151
158
 
152
159
        task_a.update('start_' + 'a' * 200 + '_end', 2000, 5000)
153
160
        view._last_transport_msg = '   123kB   100kB/s '
154
161
        line = view._render_line()
155
162
        self.assertEqual(
156
 
            '   123kB   100kB/s \\ start_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.. 2000/5000',
157
 
            line)
 
163
'   123kB   100kB/s \\ start_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.. 2000/5000',
 
164
           line) 
158
165
        self.assertEqual(len(line), 79)
159
166
 
160
167
    def test_render_progress_unicode_enc_utf8(self):