/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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