Beispiel #1
0
 def test_100_percent_bar(self):
     """Tests the default 100 percent progress bar"""
     total = 20
     bar = SimpleProgressBar()
     bar.increase(100)
     self.assertEqual("[{0}>{1}]".format('=' * (total - 1), ''),
                                         bar.progress_bar)
Beispiel #2
0
 def test_100_percent_bar(self):
     """Tests the default 100 percent progress bar"""
     total = 20
     bar = SimpleProgressBar()
     bar.increase(100)
     self.assertEqual("[{0}>{1}]".format('=' * (total - 1), ''),
                      bar.progress_bar)
Beispiel #3
0
    def test_complete_query_percent_bar(self):
        """Tests the query of complete or not complete"""
        bar = SimpleProgressBar()
        bar.increase(100)
        self.assertTrue(bar.completed())

        bar = SimpleProgressBar()
        bar.increase(99)
        self.assertFalse(bar.completed())
Beispiel #4
0
def show_simple_animation():
    bar = SimpleProgressBar()
    bar.show_progress_bar()
    while (not bar.completed()):
        time.sleep(0.1)
        bar.increase(5)
        bar.show_progress_bar()
Beispiel #5
0
    def test_decrease_bar(self):
        """Tests the decrement of the bar"""
        total = 20
        bar = SimpleProgressBar()
        bar.increase(50)
        self.assertEqual("[{0}>{1}]".format('=' * (total // 2 - 1),
                                            ' ' * (total // 2)),
                                            bar.progress_bar)

        bar.decrease(10)
        self.assertEqual("[{0}>{1}]".format('=' * (total // 2 - 3),
                                            ' ' * (total // 2 + 2)),
                                            bar.progress_bar)
def show_simple_animation():
    bar = SimpleProgressBar()
    bar.show_progress_bar()
    while(not bar.completed()):
        time.sleep(0.1)
        bar.increase(5)
        bar.show_progress_bar()
Beispiel #7
0
    def test_complete_query_percent_bar(self):
        """Tests the query of complete or not complete"""
        bar = SimpleProgressBar()
        bar.increase(100)
        self.assertTrue(bar.completed())

        bar = SimpleProgressBar()
        bar.increase(99)
        self.assertFalse(bar.completed())
Beispiel #8
0
    def test_incr_10_percent_bar(self):
        """Tests the default bar one by one"""
        bar = SimpleProgressBar()
        incr_factor = 1
        total = 20
        scale = 100
        while not bar.completed():
            total_progress = bar.progress + incr_factor
            bar.increase(incr_factor)

            filled = total * total_progress // scale
            empty = total - filled

            # Custoize The head
            char = '>' if filled > 0 else ''

            test_bar = "[{0}{1}{2}]".format('=' * (filled - 1), char,
                                            ' ' * empty)

            self.assertEqual(test_bar, bar.progress_bar)
Beispiel #9
0
    def test_incr_10_percent_bar(self):
        """Tests the default bar one by one"""
        bar = SimpleProgressBar()
        incr_factor = 1
        total = 20
        scale = 100
        while not bar.completed():
            total_progress = bar.progress + incr_factor
            bar.increase(incr_factor)

            filled = total * total_progress // scale
            empty = total - filled

            # Custoize The head
            char = '>' if filled > 0 else ''

            test_bar = "[{0}{1}{2}]".format('=' * (filled - 1),
                                            char,
                                            ' ' * empty)

            self.assertEqual(test_bar, bar.progress_bar)
Beispiel #10
0
    def test_decrease_bar(self):
        """Tests the decrement of the bar"""
        total = 20
        bar = SimpleProgressBar()
        bar.increase(50)
        self.assertEqual(
            "[{0}>{1}]".format('=' * (total // 2 - 1), ' ' * (total // 2)),
            bar.progress_bar)

        bar.decrease(10)
        self.assertEqual(
            "[{0}>{1}]".format('=' * (total // 2 - 3), ' ' * (total // 2 + 2)),
            bar.progress_bar)
Beispiel #11
0
 def test_empty_bar(self):
     """Tests the default empty progress bar"""
     total = 20
     bar = SimpleProgressBar()
     self.assertEqual("[{0}]".format(' ' * total, ), bar.progress_bar)