Esempio n. 1
0
 def test_init_progress_bar_with_length(self, mock_is_dumb_terminal):
     mock_is_dumb_terminal.return_value = self.dumb
     pb = indicators._init_progress_bar(10, "destination", "message")
     self.assertThat(pb.maxval, Equals(10))
     self.assertTrue("message" in pb.widgets)
     pb_widgets_types = [type(w) for w in pb.widgets]
     self.assertTrue(type(progressbar.Percentage()) in pb_widgets_types)
     self.assertThat(
         type(progressbar.Bar()) in pb_widgets_types, Equals(not self.dumb))
Esempio n. 2
0
 def test_init_progress_bar_with_length(self, mock_is_dumb_terminal):
     mock_is_dumb_terminal.return_value = self.dumb
     pb = indicators._init_progress_bar(10, "destination", "message")
     self.assertEqual(pb.maxval, 10)
     self.assertTrue("message" in pb.widgets)
     pb_widgets_types = [type(w) for w in pb.widgets]
     self.assertTrue(type(progressbar.Percentage()) in pb_widgets_types)
     self.assertEqual(
         type(progressbar.Bar()) in pb_widgets_types, not self.dumb)
Esempio n. 3
0
 def test_init_progress_bar_with_unknown_length(
         self, mock_is_dumb_terminal):
     mock_is_dumb_terminal.return_value = self.dumb
     pb = indicators._init_progress_bar(0, "destination", "message")
     self.assertThat(pb.maxval, Equals(progressbar.UnknownLength))
     self.assertTrue("message" in pb.widgets)
     pb_widgets_types = [type(w) for w in pb.widgets]
     self.assertThat(
         type(progressbar.AnimatedMarker()) in pb_widgets_types,
         Equals(not self.dumb))
Esempio n. 4
0
 def test_init_progress_bar_with_unknown_length(self,
                                                mock_is_dumb_terminal):
     mock_is_dumb_terminal.return_value = self.dumb
     pb = indicators._init_progress_bar(0, "destination", "message")
     self.assertEqual(pb.maxval, progressbar.UnknownLength)
     self.assertTrue("message" in pb.widgets)
     pb_widgets_types = [type(w) for w in pb.widgets]
     self.assertEqual(
         type(progressbar.AnimatedMarker()) in pb_widgets_types,
         not self.dumb)
Esempio n. 5
0
    def test_init_progress_bar_with_unknown_length(self, monkeypatch, is_dumb):
        monkeypatch.setattr(indicators, "is_dumb_terminal", lambda: is_dumb)

        pb = indicators._init_progress_bar(0, "destination", "message")

        assert pb.maxval == progressbar.UnknownLength
        assert "message" in pb.widgets

        pb_widgets_types = [type(w) for w in pb.widgets]

        assert (type(progressbar.AnimatedMarker())
                in pb_widgets_types) is not is_dumb
Esempio n. 6
0
    def test_init_progress_bar_with_length(self, monkeypatch, is_dumb):
        monkeypatch.setattr(indicators, "is_dumb_terminal", lambda: is_dumb)

        pb = indicators._init_progress_bar(10, "destination", "message")

        assert pb.maxval == 10
        assert "message" in pb.widgets

        pb_widgets_types = [type(w) for w in pb.widgets]

        assert type(progressbar.Percentage()) in pb_widgets_types
        assert (type(progressbar.Bar()) in pb_widgets_types) is not is_dumb