2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
1 |
#!/usr/bin/python
|
2 |
||
3 |
import logging |
|
4 |
import unittest |
|
5 |
||
2110
by Michael Vogt
fix tests with the dummy backend |
6 |
import dbus |
7 |
import time |
|
8 |
from gi.repository import GObject |
|
9 |
||
2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
10 |
import sys |
11 |
sys.path.insert(0,"../") |
|
12 |
||
13 |
from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend |
|
2131.1.21
by Michael Vogt
test/*: test fixes |
14 |
from softwarecenter.backend.installbackend_impl.aptd import get_dbus_bus |
2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
15 |
|
2110
by Michael Vogt
fix tests with the dummy backend |
16 |
|
2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
17 |
class TestTestUtils(unittest.TestCase): |
18 |
||
2110
by Michael Vogt
fix tests with the dummy backend |
19 |
def setUp(self): |
20 |
start_dummy_backend() |
|
21 |
||
22 |
def tearDown(self): |
|
23 |
stop_dummy_backend() |
|
24 |
||
2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
25 |
def test_start_stop_dummy_backend(self): |
26 |
bus = get_dbus_bus() |
|
27 |
system_bus = dbus.SystemBus() |
|
28 |
session_bus = dbus.SessionBus() |
|
29 |
self.assertNotEqual(bus, system_bus) |
|
30 |
self.assertNotEqual(bus, session_bus) |
|
31 |
# get names and ...
|
|
32 |
names = bus.list_names() |
|
2110
by Michael Vogt
fix tests with the dummy backend |
33 |
# ensure we have the following:
|
34 |
# org.freedesktop.DBus,
|
|
35 |
# org.freedesktop.PolicyKit1
|
|
36 |
# org.debian.apt
|
|
37 |
# (and :1.0, :1.1, :1.2)
|
|
38 |
self.assertEqual(len(names), 6) |
|
39 |
||
40 |
def test_fake_aptd(self): |
|
41 |
from softwarecenter.backend import get_install_backend |
|
42 |
backend = get_install_backend() |
|
43 |
backend.install("2vcard", "", "") |
|
44 |
self._p() |
|
45 |
||
46 |
def _p(self): |
|
47 |
context = GObject.main_context_default() |
|
48 |
for i in range(10): |
|
49 |
while context.pending(): |
|
50 |
context.iteration() |
|
51 |
time.sleep(0.1) |
|
52 |
||
2095.1.2
by Michael Vogt
test/test_testutils.py: add test for testutils, fixups in the progress test |
53 |
|
54 |
if __name__ == "__main__": |
|
55 |
logging.basicConfig(level=logging.DEBUG) |
|
56 |
unittest.main() |