File: test_progress.py

package info (click to toggle)
aptdaemon 1.1.1-4%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 7,456 kB
  • ctags: 3,911
  • sloc: python: 13,428; sh: 88; makefile: 23
file content (49 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests the debconf forwarding"""

import apt
import logging
import mock
import sys
import unittest

from aptdaemon.progress import DaemonOpenProgress


class TestProgress(unittest.TestCase):

    def test_open_progress(self):
        transaction = mock.Mock()
        begin = 0
        end = 5
        d = DaemonOpenProgress(transaction, begin=begin, end=end)
        # simulate cache open (c = apt.Cache(d)))
        for j in range(4):
            for i in range(0, 100, 10):
                d.update(i)
                self.assertTrue(d.progress >= begin)
                self.assertTrue(d.progress <= end)
            d.done()
        # ensure we use the full range
        self.assertEqual(d.progress, end)

    def test_open_progress_real_cache(self):
        transaction = mock.Mock()
        begin = 0
        end = 5
        d = DaemonOpenProgress(transaction, begin=begin, end=end)
        c = apt.Cache(d)
        # ensure we use the full range
        self.assertEqual(d.progress, end)


@unittest.skipIf(sys.version_info.major < 3, "Python 3 only")
def setUp():
    pass

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    unittest.main()

# vim: ts=4 et sts=4